得到了我想要的工作,但是我可以对其进行哪些更新以使其更好?
代码: - - - - - - - - - - - - - - - - - - - -
$odb = new PDO('mysql:host=localhost;dbname=db371885849', $user, $pass);
$odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$q = "INSERT INTO jobform(firstname, lastname, email) VALUES (:firstname, :lastname, :email);";
$query = $odb->prepare($q);
$results = $query->execute(array(
":firstname" => $firstname,
":lastname" => $lastname,
":email" => $email
));
}
++++++++++++++++++++++++++更新工作++++++++++++++++++++++++ ++
$odb = new PDO('mysql:host=localhost;dbname=db371885849', $user, $pass);
$odb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_POST['firstname'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
if (!empty($firstname))
{
$q = "INSERT INTO jobform(firstname, lastname, email) VALUES (:firstname, :lastname, :email);";
$query = $odb->prepare($q);
$results = $query->execute(array(
":firstname" => $firstname,
":lastname" => $lastname,
":email" => $email
));
} else {
echo "not today";
}
}