**我想存储从 $_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]']; }}'''
1 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
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'])){
- 1 回答
- 0 关注
- 101 浏览
添加回答
举报
0/150
提交
取消