**我想把$_POST中的数据存储到$_SESSION中,当用户点击提交按钮时,这些数据会在特定的条件下合适,我需要把经过认证的$_Session数组发送到另一个页面。但是,我的代码不能正常工作。谁能帮帮我吗:(**)
'''
session_start();
$errorFound = 0;
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialChars($data);
return $data;
}
$cleanData_CUST_name = $_POST['cust']['cust[name]'];
if (isset($_POST['submit_booking'])){
if (empty($_POST["cust[name]"])) {
$nameErr = "Name is required";
$errorFound++;
} else {
$name = test_input($_POST["cust[name]"]);
if (!preg_match("/^[a-zA-Z ]*$/", $name)){
$nameErr = "Only letters and whitespace are allowed.";
$errorFound++;
}if($errorFound ==0){
$_SESSION['CUST'] = $_POST['cust[name]'];
}
}
'''
if (isset($_POST['submit_booking'])){
if (empty($_POST["cust[name]"])) {
$nameErr = "Name is required";
$errorFound++;
} else {
$name = test_input($_POST["cust[name]"]);
if (!preg_match("/^[a-zA-Z ]*$/", $name)){
$nameErr = "Only letters and whitespace are allowed.";
$errorFound++;
}if($errorFound ==0){
$_SESSION['CUST'] = $_POST['cust[name]'];
}
}
}
你缺少了一个分号来关闭 if (isset($_POST['submit_booking'])){