我是 php 验证的新手。我正在处理注册表单,它将通过 php 脚本进行数据库检查两个 unqiue 变量ac_title
,email
然后检查错误。它将在数据库中插入给定的值。文件名是formvu.php
然后它会移动到activate.php
. 我遇到的问题是,如果我使用
<form name="fone" method="post" onsubmit="return validateform(fone)" action="activate.php">
表单将忽略 php 脚本,并将移至下一页。什么时候我会用这个:
<form name="fone" method="post" onsubmit="return validateform(fone)" action="<?php $_SERVER['PHP_SELF']?> ">
现在页面它将运行整个 php 错误和命令。
这是我的整个php代码:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$nun=$_POST['account'];
$em=$_POST['email'];
$register="SELECT ac_title,email FROM register";
$query=mysql_query($register);
while ($row= mysql_fetch_array($query))
{
if ($nun == $row['ac_title'])
{
print "<span class=\"phclass\"><br/><b>
Your Account Title :</b></span>"." '"."<span class=\"ahclass\"><b>$nun</b></span>"."'".
" <span class=\"phclass\"><b>already exsist, please choose different.</b></span><br/>";
}
if($em == $row['email'])
{
print "<span class=\"phclass\"><b><br/>Your Email:</b>
</span>"." "."<span class=\"phclass\"><b> $em</b></span>"."<span class=\"phclass\">
<b> already exsist, please visit <a href=\"resetpassword.html\">
Forget password</a></b></span><br/>";
}
if ($nun != $row['ac_title'] && $em != $row['email'])
{
$ac_title=$_POST['account'];
$email=$_POST['email'];
$pass=$_POST['pwd'];
$fn=$_POST['fname'];
$gd=$_POST['gender'];
$city=$_POST['city'];
$VID=$_POST['vuid'];
$course=$_POST['courseid'];
$camp=$_POST['campus'];
$hash=md5(rand(0,1000));
$sql="INSERT INTO register (ac_title, email, pass,fn, sex, city,
VID, CRS, campus, hash,activate) VALUES('$ac_title', '$email',
'$pass','$fn', '$gd',' $city','$VID','$course',
'$camp','$hash','0')";
$inst=mysql_query($sql,$connection);
if (!$inst)
{
print "";
}
else
{
echo "Succesful ";
}
}// if
} // while
} // if
?>
如果该操作是默认页面,它将运行整个脚本。我想运行整个脚本并移至下一页 ( activate.php
)。