try {
$results = $db->prepare("INSERT INTO Form_Data
(first_name, last_name, email, gender, comment)
VALUES
(?,?,?,?,?)
");
$results->bindParam(1,$fname,PDO::PARAM_STR);
$results->bindParam(2,$lname,PDO::PARAM_STR);
$results->bindParam(3,$email);
$results->bindParam(4,$gender);
$results->bindParam(5,$comment,PDO::PARAM_STR);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$results->execute();
}
} catch (Exceptions $e) {
echo "Unable to insert data";
exit;
}
Do I need to use the if($_SERVER["REQUEST_METHOD] == "POST") statement? Or can I just use $results->execute();? And why?
Aucun commentaire:
Enregistrer un commentaire