我正在尝试制作我的学校项目,并希望建立一个登录系统和注册系统......我的登录查询很好,但我的注册时间花了很多时间...我已经在这里待了3-4个小时试图计算现在我正在哭...我已经做了一切....所以在我迫切的需要我问这个社区...请提供即时答案我迫切需要它......问题是......我似乎无法我输入我的表格的数据... ...它...我不知道背后的原因是什么
if($_POST['registerbtn'])
{
$getuser = $_POST['user'];
$getemail = $_POST['email'];
$getpass = $_POST['pass'];
$getconfirmation = $_POST['confirmation'];
if($getemail){
if($getuser){
if($getpass){
if($getconfirmation){
if( $getpass === $getconfirmation ){
if( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, "."))) {
require("./Connect.php");
$query = mysql_query("SELECT * FROM users WHERE username='$getuser'");
$numrows = mysql_num_rows($query);
if($numrows == 0){
$query = mysql_query("SELECT * FROM users WHERE email='$getemail'");
$numrows = mysql_num_rows($query);
if($numrows == 0){
$date = date("F d, Y");
$code = rand();
mysql_query("INSERT INTO users VALUES('', '$getuser', '$getemail', '$getpass', '$date' )");
mysql_query("SELECT * FROM users WHERE username='$getuser'");
$numrows = mysql_num_rows($query);
if($numrows == 1){
}else
$errormsg = "An Error Has Occurred. Account Not Processed";
}else
$errormsg ="There is already a user with that email.";
}else
$errormsg ="There is already a user with that username.";
mysql_close();
}else
$errormsg = "You must enter a valid email address";
}else
$errormsg = "Your passwords did not match";
}else
$errormsg = "Confirm your password";
}else
$errormsg = "You must enter your password";
}else
$errormsg = "You must enter your username";
}else
$errormsg = "You must enter your email address";
}
$form = "<form action='./register.php' method='post'>
<table>
<tr>
<td></td>
<td><font color='red'>$errormsg</font></td>
</tr>
</table>
<fieldset>
<legend>Account</legend>
<input type='text' name='user' size='15' value='$getuser'/>:Username<br/>
<input type='text' name='email' size='15'value='$getemail'>:Email<br/>
<input type='password' name='pass' size='15' value=''/>:Passcode<br/>
<input type='password' name='confirmation' size='15' value=''/>:Confirmation<br/>
<br/>
<input type='submit' name='registerbtn' value='EAT ME'/>
</fieldset>
</form>";
echo "$form";
?>
答案 0 :(得分:0)
如果您在同一页面提交表格。
$form = "<form action='' method='post'>
试试这个..
if(isset($_POST['registerbtn']))
而不是
if($_POST['registerbtn'])
和
如果你的Connect.php和注册在同一个文件夹中,那么如果在文件夹之外,请使用require("Connect.php");
然后给出正确的路径
答案 1 :(得分:0)
首先,除了registerbtn之外,如果没有将变量设置为“”,则需要检查变量是否已设置。
像这样:
<?php
if(isset($_POST['registerbtn']))
{
...
} else {
$getuser = $getemail = $errormsg = "";
}
$form = "<form action='./register.php' method='post'>
<table>
<tr>
<td></td>
<td><font color='red'>$errormsg</font></td>
</tr>
</table>
<fieldset>
<legend>Account</legend>
<input type='text' name='user' size='15' value='$getuser'/>:Username<br/>
<input type='text' name='email' size='15'value='$getemail'>:Email<br/>
<input type='password' name='pass' size='15' value=''/>:Passcode<br/>
<input type='password' name='confirmation' size='15' value=''/>:Confirmation<br/>
<br/>
<input type='submit' name='registerbtn' value='EAT ME'/>
</fieldset>
</form>";
echo "$form";
如果db部分没有任何问题,它应该可以工作。
在其中一个if-conditionals中:
if($numrows == 1){
}else
$errormsg = "An Error Has Occurred. Account Not Processed";
这不是必需的,因为if($numrows == 0 )
的其他人负责处理它。
答案 2 :(得分:0)
将<form action='./register.php' method='post'>
更改为<form action='' method='post'> or <form action='#' method='post'>