我的脚本有问题,它是几年前在 Uni 中为作业创建的,当时它运行良好,但我没有收到此通知,现在对于每个字段,我都会收到“通知:未定义索引”。
我读过这与未能声明变量有关,我需要起诉 isset 吗?但我仍然不确定如何在代码中实现它。
这是代码:
<?php
require 'server.php';
$results = $dbh->prepare('SELECT * FROM details WHERE id = :id');
$results->execute(array(
':id' => $_GET['id'],
));
if (isset($_POST['submit'] )) header("Location: template/header.php"); {
$update = $dbh->prepare('UPDATE details SET firstname = :firstname, surname = :surname, houseno = :houseno, street = :street, town= :town,
county = :county, postcode = :postcode, mobile = :mobile, nickname = :nickname, website = :website,
homephone = :homephone WHERE id = :id');
$update->execute(array(
':id' => $_POST['id'],
':firstname' => $_POST['firstname'],
':surname' => $_POST['surname'],
':houseno' => $_POST['houseno'],
':street' => $_POST['street'],
':town' => $_POST['town'],
':county' => $_POST['county'],
':postcode' => $_POST['postcode'],
':mobile' => $_POST['mobile'],
':nickname' => $_POST['nickname'],
':website' => $_POST['website'],
':homephone' => $_POST['homephone'],
));
$row = $results->fetch();
}
require 'template/header.php';
?>
关于如何解决问题的任何想法?图片在这里: