I am new to php so I used a Youtube tutorial to create this script, however the uploader seems to have disappeared so I cannot ask him any questions. My login form seems to work fine but the registration form is where I am having trouble
I have removed all html from code and all error else statements to try eliminate the error message but I cant seem to find it. Error always occurs at the end of my script.
Any suggestions
<?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 = "[email protected]";
$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;
}
?>