Hello all,
I have a working mysql database with my PHP code. I can create a new row and delete a row BUT when I click the btn delete the page just continually keeps loading and never goes to my header(). For my create btn the page does the same thing just keeps
Is PDO one of the best phps to use these days?
For doing prepared statements how is this for my example of code below. Anything that i should do differently?
Can you all look at this.
How do you think this is for my prepared statements. Someone said PDO PHP is the way PHP should be used now adays? Is the correct.
Here is my prepared statement. Am I doing everything correctly or what should i change? loading. Here is my code.
if(isset($_POST["id"]) && !empty($_POST["id"])) {
require_once "php/config.php";
$sql = "DELETE FROM users WHERE id=:id";
if($stmt = $pdoConnect->prepare($sql)) {
$stmt->bindParam(":id", $param_id);
$param_id = trim($_POST["id"]);
if($stmt->execute()) {
header("location: index.php");
exit();
} else {
echo "Something went wrong with DELETE.";
}
}
unset($stmt);
unset($pdoConnect);
} else {
if(empty(trim($_GET["id"]))) {
header("location: error.php");
exit();
}
}
$sql = "INSERT INTO users(name, language, date) VALUES " .
"(:name, :language, :date)";
if($stmt = $pdoConnect->prepare($sql))
{
$stmt->bindParam(":name", $para_name);
$stmt->bindParam(":language", $para_lang);
$stmt->bindParam(":date", $para_date);
$para_name = $name;
$para_lang = $language;
$para_date = $currentDate;
if($stmt->execute())
{
header("Location:index.php");
exit();
} else {
echo "Something went wrong with INSERT, please try again later.";
}
What I have tried:
My page just keeps loading and never executes a new page I also have a question about PHP langauge what one should i be using now adays PDO? and is that ok for doing parameters how i have mine setup in the code?