我是 php 新手,所以我使用了一个 Youtube 教程来创建这个脚本,但是上传者似乎已经消失了,所以我不能问他任何问题。我的登录表单似乎工作正常,但注册表是我遇到问题的地方
我已经从代码中删除了所有 html 和所有错误 else 语句以尝试消除错误消息,但我似乎找不到它。错误总是发生在我的脚本末尾。
有什么建议么
<?php
if ( $_POST['registerbtn'] ) {
//makes sure email, username is valid
$getuser = $_POST['user'];
$getemail = $_POST['email'];
$getpass = $_POST['pass'];
$getretypepass = $_POST['retypepass'];
if (!isset($getuser))
{
$error = "user not set ";
}
if ($getuser) {
if($getemail) {
if($getpass) {
if ($getretypepass) {
require("connection.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) {
$password = md5(md5("19Dvdnj".$password."jndfFf20"));
$date = date("F d, Y");
$code = md5(rand());
mysql_query("INSERT INTO users VALUES ('', '$getuser', '$password', '$getmail', '0', '$code', '$date')");
$query = mysql_query("SELECT * FROM users WHERE username='$getuser'");
$numrows =mysql_num_rows($query);
if ($numrows == 1) {
$site ="http://www.inn.leedsmet.ac.uk/~c3314283/iis/register.php";
$webmaster = "admin@leedsmet.com";
$headers = "From: $webmaster";
$subject ="Activate your Account";
$message = "Thanks for registering. Click below to activate your account.\n";
$message .= "$site/activate.php?user=$getuser&code=$code";
$message .= "You must activate your account to login";
if (mail($getmail, $subject, $message, $headers)){
$errormsg = "You have been registered you must activate your account sent from the the activation link sent to<b>$getemail</b>";
$getuser = "";
$getemail = "";
}
mysql_close();
$form ="<form action='register.php' method='post'>
<table>
<tr>
<td></td>
<td><font color='red'>$errormsg</font></td>
</tr>
<tr>
<td>Username:</td>
<td><input type='text' name='user' value ='$getuser'/></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' value ='$getemail'/></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='pass' value =''/></td>
</tr>
<tr>
<td>Retype:</td>
<td><input type='password' name='retypepass' value =''/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='registerbtn' value ='Register'/></td>
</tr>
</table>
</form>";
{
echo $form;
}
?>