该表似乎更新了,但它没有将我重定向到主页面。我尝试了不同的事情,没有运气。如果有人可以帮助我。提前你。我只会提供更新代码,如果需要我将完整的代码页面。
$id_actividades = $_GET['idactividades'];
include('../includes/eamoschema.php');
$stmt = $dbh->prepare("SELECT * FROM actividades WHERE idactividades=:id_actividades");
$stmt -> bindParam(':id_actividades', $id_actividades);
$stmt->execute();
$result = $stmt->fetchall(PDO::FETCH_ASSOC);
if($_SERVER['REQUEST_METHOD']== 'POST'){
if (isset($_POST['tname']) || isset($_POST['place']) || isset($_POST['organizer']) || isset($_POST['from']) || isset($_POST['to']) ) {
$tname = $_POST['tname'];
$place = $_POST['place'];
$organizer = $_POST['organizer'];
$from = $_POST['from'];
$to = $_POST['to'];
try{
$stmt = $dbh->prepare("UPDATE guaynabodb.actividades SET ntorneo = :n_torneo, ltorneo = :l_torneo, otorneo = :o_torneo, fecha_inicial = :from, fecha_final = :to WHERE idactividades=:id_actividades");
$stmt -> bindParam(':n_torneo', $tname);
$stmt -> bindParam(':l_torneo', $place);
$stmt -> bindParam(':o_torneo', $organizer);
$stmt -> bindParam(':from', $from);
$stmt -> bindParam(':to', $to);
$stmt -> bindParam(':id_actividades', $id_actividades);
$stmt->execute();
}
catch (PDOException $ex) {
$_SESSION['errorCode3'] =$ex->getMessage();
header('Location: actividades.php?errorCode=3');//To redirect
exit;
}
header('Location:actividades.php');//To redirect
exit;
}
}
答案 0 :(得分:1)
您的最大和最重要问题缺少错误报告。
它不仅在这种特殊情况下破坏了你,而且还破坏了你对PHP的整体体验 每当出现问题时,PHP都会告诉你 - 发生了什么以及应该责怪谁。只有你这样做。但你没有。
在实际网站上,您必须查看错误日志,因此,您必须以这种方式配置PHP:
error_reporting(E_ALL);
ini_set('display_errors',0);
ini_set('log_errors',1);
在本地开发服务器上,可以在屏幕上出错:
error_reporting(E_ALL);
ini_set('display_errors',1);
只要您有错误,您就会知道该怎么做:只需在Google上搜索其文字即可。您将立即找到答案,因为它是有史以来最流行的PHP错误消息。