我正在尝试将表单中的值携带到我的“Formhandler”文档中,但我无法让它工作。我尝试在我的 html 标签中添加一个值(Register),但没有奏效。我知道这是我需要更改的表单中的“隐藏”输入字段,我自己无法解决。这可能是一个简单的修复,但我看不到它,需要重新审视这个问题。非常感谢你。
<form id="signinform" action="<?php echo url_for('../Private/createuser.php');?>" method="post">
<input type="hidden" name="action" id="action" value="Register" />
<div class="formcontainer">
<div class="formrow">
<div class="formlabel">
Email
</div>
<div class="formfield">
<input type="text" name="Email" id="Email" class="required" />
</div>
</div>
<div class="formrow">
<div class="formlabel">
First Name
</div>
<div class="formfield">
<input type="text" name="First_name" id="First_name" class="required" />
</div>
</div>
<div class="formrow">
<div class="formlabel">
Surname
</div>
<div class="formfield">
<input type="text" name="Surname" id="Surname" class="required" />
</div>
</div>
<div class="formrow">
<div class="formlabel">
Password
</div>
<div class="formfield">
<input type="password" name="Password" id="Password" class="required" />
</div>
</div>
<div class="formrow">
<div class="longformlabel"><input type="submit" value="Register" class="formbutton" /></div>
</div>
</div>
</form>
然后表单处理程序代码是;
if($_POST['action']=='Register') {
//VALIDATION------------------------------------------------------------------------------------------
$validated = new FormValidator();
$validflag=true;
if($validated->validateItem($_POST['Email'], 'email')) {
$email=$validated->sanatizeItem($_POST['Email'], 'string');
} else {
$validflag=false;
}
//END VALIDATION------------------------------------------------------------------------------------------
if($validflag=true) {
$usercheck=mysqli_query($db,"SELECT * FROM `Users`
WHERE `Email`='{$_POST[$email]}'");
if(mysqli_num_rows($usercheck)>0) {
$_SESSION['message']="Email address already in our database - please login or try registering a new account.";
header("location: signup.php" . $processtext);
}
$bcrypt = new Bcrypt(15);
$salt=$bcrypt->getSalt();
$hash = $bcrypt->hash($_POST['Password'],$salt);
$sql1 = "INSERT INTO Users ";
$sql1 .= "(Email, Password) ";
$sql1 .= "VALUES (";
$sql1 .= "'" . $email . "',";
$sql1 .= "'" . $hash . "',";
$sql1 .= ")";
$sql = "INSER INTO saltuser ";
$sql .= "(Email, Saltstring) ";
$sql .= "VALUES (";
$sql .= "'" . $email . "',";
$sql .= "'" . $salt . "'";
$sql .= ")";
$result = mysqli_query($saltdb, $sql);
$result1 = mysqli_query($db, $sql1);
} else {
// INSERT failed
echo mysqli_error($db);
db_disconnect($db);
exit;
}
}
来自表单处理程序的日志中的错误表明“操作”未定义。请帮忙。