如何在特定条件下在一个会话中存储值

how to store values in one session in a certain condition

**我想将数据从 $_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'])){

的分号