我想创建一个cofirm命令页面,该用户在选择产品后使用CONFIRM FORM确认命令,然后将他重定向到cofirm页面,在那里他必须写下他们的日期以确认命令(用户日期) )
所以我在页面cart.php中有一个数组
$cofirmaComanda .='<form action="cofirma_comanda.php" method="post">
<input name="prettotal" type="hidden" value="'. $pricetotal .'">
<input name="produseID" type="hidden" value="'. $item_id .'">
<input name="produseNume" type="hidden" value="'. $product_name .'">
<input name="size" type="hidden" value="'. $my_ArraySize .'">
<input name="cantitate" type="hidden" value="' . $each_item['quantity'] .'">
<input name="produse" type="hidden" value="'. $item_id .'">
<input type="submit" name="CofirmaComanda" value="cofirma_comanda"></form>';
然后是cofirm页面
<?php
session_start(); // Start session first thing in script
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
?>
<?php
$pretTotal = $_POST["prettotal"];
$PRODUSE = $_POST["produseID"];
$produseNume = $_POST["produseNume"];
$size = $_POST["size"];
$cantitate = $_POST["cantitate"];
echo "ID: ".$PRODUSE."<br>";
echo "nume produs selectat: ".$produseNume." <br>";
echo $pretTotal." preata total in LEI<br>";
echo $cantitate." cantitate<br>";
echo $size." dimensiune<br>";
// Filter Function -------------------------------------------------------------------
function filterFunction ($var) {
$var = nl2br(htmlspecialchars($var));
$var = str_replace("/", "\\\\", $var);
$var = preg_replace("~/~", "\\\\", $var);
return $var;
}
$pretTotal = filterFunction($pretTotal);
$PRODUSE = filterFunction($PRODUSE);
$produseNume = filterFunction($produseNume);
$size = filterFunction($size);
$cantitate = filterFunction($cantitate);
if(isset($_SESSION["sumbitDateClienti"])){
$nume = $_POST["nume_client"];
$comanda = 'IDprodus: '.$PRODUSE.' / produseNume: '.$produseNume.' / cantitate: '.$cantitate.' / dimensiune: '.$size.' ';
$stmt = $con->prepare("INSERT comanda (pret_comanda, comanda) VALUES (?, ?)");
// TODO check that $stmt creation succeeded
// "s" means the database expects a string
$stmt->bind_param("ss", $pretTotal, $comanda);
$stmt->execute();
if($stmt->execute()) {
echo "<strong>succes</strong> pagina a fost creata\n titlu: n<a href='admin_index_istorie.php'><strong>Inapoi la pagina de modificare istorie</strong></a>";
}
else {
echo "eroare";
}
$stmt->close();
}
else{
echo "completeaza forum pentru a finaliza comanda";
}
?>
cofirm页面上的表格
<form action="" method="post">
nume: <input name="nume_client" type="text">
<input type="hidden" name="prettotal" value="<?php echo $_POST['prettotal'] ?>">
<input type="hidden" name="produseID" value="<?php echo $_POST['produseID']; ?>">
<input type="hidden" name="produseNume" value="<?php echo $_POST['produseNume']; ?>">
<input type="hidden" name="cantitate" value="<?php echo $_POST['cantitate']; ?>">
<input type="hidden" name="size" value="<?php echo $_POST['size']; ?>">
<input type="submit" name="sumbitDateClienti" value="ok">
</form>
我遇到了这个问题,因为如果我在字段上放一个名字就是在做,不会在数据库中插入查询,也不会给我带错误的其他返回