由于PHP,我正在进行重定向,但它根本不重定向(但会进行其他重定向)。
这是我实现的代码:
<?php
session_start(); // pour pouvoir récupérer /creer desvariables de session
try
{
$bdd = new PDO('mysql:host=localhost;dbname=youf', 'root', 'root');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$redirection="command.php";
if (!isset($_SESSION['Login'])){ header('Location: connect.php'); } // Si pas de sessionactives, redirect
if (!isset($_SESSION['CommandId'])){
$long = strlen($_SESSION['Login']);
$table = $_SESSION['Login'][$long-2].$_SESSION['Login'][$long-1];
$zone = $_SESSION['Login'][$long-4].$_SESSION['Login'][$long-3];
$createCommand="INSERT INTO `youfood`.`command` (`Number`, `Date`, `isPaid`, `Table`, `Zone`, `Server`, `State`) VALUES (NULL, current_date, '0', '".$table."', '".$zone."', '".$_SESSION['NumberEmployee']."', '5');";
$bdd->query($createCommand);
$sqlCommandNumber=$bdd->query("SELECT * FROM `command` WHERE `Table` =".$table." AND `Zone` =".$zone." AND `State` =0 LIMIT 0 , 1");
$commandNumber="";
while ($data=$sqlCommandNumber->fetch()){
$commandNumber = $data['Number'];
}
$_SESSION['CommandId'] = $commandNumber ;
header('Location: actionValidateCommand.php');
$redirection="actionValidatedCommand.php";
} else {
foreach ( $_SESSION['cart'] as $key => $value ) {
if($value != 0){
$sql = "INSERT INTO `youfood`.`commanddishe` (`Number` ,`command` ,`Dishe` ,`Quantity`)VALUES (NULL, '".$_SESSION['CommandId']."', '".$key."', '".$value."')";
$bdd->query($sql);
$messagee = $messagee."<br />".$sql."<br />";
$_SESSION['cart'][$key] = 0 ;
}
}
header('Location: command.php');
$redirection="command.php";
}
?>
<!DOCTYPE html>
<html>
当我检查未重定向页面的 html 结果时,我看到标签前有一个空格。我不知道空间在哪里,我知道这是错误的!
感谢帮助我:-)