**我想存储从 $_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]'];
}
}
'''
哆啦的时光机