Jump to content

Creating Register Script


Brenton

Recommended Posts

So I've been coding a register script, and I've reached an error.

Nothing displays on the webserver.

Just a blank page.

 

If anyone could help, that would be great.

 

That is the code.

You can preview it live at: http://nordaea.phpnet.us/register.php

 

<?php

if ($_GET['act'] == "agree") {

	if ($_GET['act'] == "submit") {
// For register_global on PHP settings
$name = $_POST['name'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$password_verify = $_POST['password_verify'];
$birthdate = $_POST['birthdate'];
$birthmonth = $_POST['birthmonth'];
$birthyear = $_POST['birthyear'];

// Check for empty fields
if ( empty($username) || empty($email) || empty($password) || empty($password_verify)  || empty($name) || empty($birthdate) || empty($birthmonth) || empty($birthyear)) {
    die ("Error! Please fill in <b>all</ b> fields, they are all required. <br /> <a href="register.php?act=agree">Go Back</a>");
}

// Check that email is valid
if (!(ereg ("^.+@.+\..+$", $email))) {
	die ("Error. $email appears to be invalid, please enter a valid email. <br /> <a href="register.php?act=agree">Go Back</a>");
} 

//  Create 6 digit activation code
function randomstring($len)	{
	srand(date("s"));
	while($i<$len) {
		$str.=chr((rand()%26)+97);
		$i++;
	}

	$str=$str.substr(uniqid (""),0,22);
	return $str;
}

// Now generate the 6-digit code
$code = randomstring(6);    // 6 for a 6-digit code
$code = substr("$code", 0, 6);

// Now email the user registration details
    $from = "accounts@nordaea.com";
    $subject = "Registration @ Nordaea"; 

    $headers = "MIME-Version: 1.0\r\n"; 
    $headers = "From: Nordaea<$from>\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

    $message = "Hi $name, <br><br> Thank you for creating an account at Nordaea! Below is the information you registered with, and the information required to activate your account: <br>";
    $message .= "Username: $username<br> Password: $password <br> ";
    $message .= "First to access your account, you must activate it, please paste the following link into your web broswer: <strong>http://nordaea.com/register.php?act=activate&code=$code</strong> to activate your account.<br><br>";
    $message .= "If you have any problems whatsoever activating your account, please reply to this email with your problem, please be as detailed as possible.";
    
if (mail($email,$subject,$message,$headers)) {    // if mail is successful
        // Store data into database
        $insert = "insert into membership (name, username, email, password, password_verify, birthdate, birthmonth, birthyear) VALUES (So yes, according to the PHP tutorials i read, values go here, but I have NO idea how to do it properly.)";
        $query = mysql_query($insert) or die     ("Could not execute: $query." . mysql_error());
        
        if ($query) {
            echo "<p>Thank you $name. Please check your email, information about how to activate your account has been sent to $email, if you cannot find the email in your inbox be sure to take a look at your junk mails.</p>";
        } 

}
}	echo "
	<center><form action='register.php?act=submit' method='post'>
	Username: <input type='text' name='username' maxlength='15'><br />
	Password: <input type='password' name='password' maxlength='16'> <br />
	Verify Password: <input type='password' name='password_verify' maxlength='16'> <br />
	Email: <input type='text' name='email' maxlength='40'> <br />
	Your Name: <input type='text' name='name' maxlength='18'> <br />
	Date of Birth: 
	<select name='birthdate'>
	";
	for ($date = 01; $date < 32; $date++) {
		echo "<option value=".$date.">".$date."</option>";
	}
	echo "
	</select>
	<select name='birthmonth'>
	";
	for ($month = 01; $month < 13; $month++) {
		echo "<option value=".$month.">".$month."</option>";
	}
	echo "
	</select>
	<select name='birthyear'>
	";
	for ($year = 1900; $year < 2007; $year++) {
		echo "<option value=".$year.">".$year."</option>";
	}
	echo "
	</select><br />
	<input type=submit value=Register>
	</form></center>
	";
} else if ($_GET['act'] == "disagree") {
	echo '<table width="50%" border="0"><tr><td><b>Disagree to the Terms & Conditions</b><br>
	You may not be a member of Nordaea if you are not in full acceptance of the terms.
	</tr></td></table>';
} else {
	echo <<<END
	<center><table width="50%" border="0"><tr><td>
	<b>Register at Nordaea</b><br />
	You must first read, understand and agree to the Terms and Conditions and Privacy Policy. By accepting this agreement, you also acknowledge that you are 13 years + or that you have parental consent to register an account at Nordaea.<br>
	<center><a href="register.php?act=agree">I agree to these terms and am 13 years + or have parental consent to create an account</ a><br>
	<a href="register.php?act=disagree">I do not agree to these terms</ a></center>
	</tr></td></table></center>
	END;
}
}
?>

Link to comment
Share on other sites

 

change this

} else {
	echo <<<END
	<center><table width="50%" border="0"><tr><td>
	<b>Register at Nordaea</b><br />
	You must first read, understand and agree to the Terms and Conditions and Privacy Policy. By accepting this agreement, you also acknowledge that you are 13 years + or that you have parental consent to register an account at Nordaea.<br>
	<center><a href="register.php?act=agree">I agree to these terms and am 13 years + or have parental consent to create an account</ a><br>
	<a href="register.php?act=disagree">I do not agree to these terms</ a></center>
	</tr></td></table></center>
	END;
}

 

to this

 


} else { ?>
	echo <<<END		<center><table width="50%" border="0"><tr><td>
	<b>Register at Nordaea</b><br />
	You must first read, understand and agree to the Terms and Conditions and Privacy Policy. By accepting this agreement, you also acknowledge that you are 13 years + or that you have parental consent to register an account at Nordaea.<br>
	<center><a href="register.php?act=agree">I agree to these terms and am 13 years + or have parental consent to create an account</ a><br>
	<a href="register.php?act=disagree">I do not agree to these terms</ a></center>
	</tr></td></table></center>

<?	}

 

 

Link to comment
Share on other sites

It's still blank, have I done something wrong?

Here's the code now.

<?php

if ($_GET['act'] == "agree") {

	if ($_GET['act'] == "submit") {
// For register_global on PHP settings
$name = $_POST['name'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$password_verify = $_POST['password_verify'];
$birthdate = $_POST['birthdate'];
$birthmonth = $_POST['birthmonth'];
$birthyear = $_POST['birthyear'];

// Check for empty fields
if (empty($username) || empty($email) || empty($password) || empty($password_verify)  || empty($name) || empty($birthdate) || empty($birthmonth) || empty($birthyear)) {
    die ("Error! Please fill in <b>all</ b> fields, they are all required. <br /> <a href="register.php?act=agree">Go Back</a>");
}

// Check that email is valid
if (!(ereg ("^.+@.+\..+$", $email))) {
	die ("Error. $email appears to be invalid, please enter a valid email. <br /> <a href="register.php?act=agree">Go Back</a>");
} 

//  Create 6 digit activation code
function randomstring($len)	{
	srand(date("s"));
	while($i<$len) {
		$str.=chr((rand()%26)+97);
		$i++;
	}

	$str=$str.substr(uniqid (""),0,22);
	return $str;
}

// Now generate the 6-digit code
$code = randomstring(6);    // 6 for a 6-digit code
$code = substr("$code", 0, 6);

// Now email the user registration details
    $from = "accounts@nordaea.com";
    $subject = "Registration @ Nordaea"; 

    $headers = "MIME-Version: 1.0\r\n"; 
    $headers = "From: Nordaea<$from>\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 

    $message = "Hi $name, <br><br> Thank you for creating an account at Nordaea! Below is the information you registered with, and the information required to activate your account: <br>";
    $message .= "Username: $username<br> Password: $password <br> ";
    $message .= "First to access your account, you must activate it, please paste the following link into your web broswer: <strong>http://nordaea.com/register.php?act=activate&code=$code</strong> to activate your account.<br><br>";
    $message .= "If you have any problems whatsoever activating your account, please reply to this email with your problem, please be as detailed as possible.";
    
if (mail($email,$subject,$message,$headers)) {    // if mail is successful
        // Store data into database
        $insert = "insert into membership (name, username, email, password, password_verify, birthdate, birthmonth, birthyear) VALUES (So yes, according to the PHP tutorials i read, values go here, but I have NO idea how to do it properly.)";
        $query = mysql_query($insert) or die     ("Could not execute: $query." . mysql_error());
        
        if ($query) {
            echo "<p>Thank you $name. Please check your email, information about how to activate your account has been sent to $email, if you cannot find the email in your inbox be sure to take a look at your junk mails.</p>";
        } 

}
}	echo "
	<center><form action='register.php?act=submit' method='post'>
	Username: <input type='text' name='username' maxlength='15'><br />
	Password: <input type='password' name='password' maxlength='16'> <br />
	Verify Password: <input type='password' name='password_verify' maxlength='16'> <br />
	Email: <input type='text' name='email' maxlength='40'> <br />
	Your Name: <input type='text' name='name' maxlength='18'> <br />
	Date of Birth: 
	<select name='birthdate'>
	";
	for ($date = 01; $date < 32; $date++) {
		echo "<option value=".$date.">".$date."</option>";
	}
	echo "
	</select>
	<select name='birthmonth'>
	";
	for ($month = 01; $month < 13; $month++) {
		echo "<option value=".$month.">".$month."</option>";
	}
	echo "
	</select>
	<select name='birthyear'>
	";
	for ($year = 1900; $year < 2007; $year++) {
		echo "<option value=".$year.">".$year."</option>";
	}
	echo "
	</select><br />
	<input type=submit value=Register>
	</form></center>
	";
} else if ($_GET['act'] == "disagree") {
	echo '<table width="50%" border="0"><tr><td><b>Disagree to the Terms & Conditions</b><br>
	You may not be a member of Nordaea if you are not in full acceptance of the terms.
	</tr></td></table>';
} else { ?>
	echo <<<END		<center><table width="50%" border="0"><tr><td>
	<b>Register at Nordaea</b><br />
	You must first read, understand and agree to the Terms and Conditions and Privacy Policy. By accepting this agreement, you also acknowledge that you are 13 years + or that you have parental consent to register an account at Nordaea.<br>
	<center><a href="register.php?act=agree">I agree to these terms and am 13 years + or have parental consent to create an account</ a><br>
	<a href="register.php?act=disagree">I do not agree to these terms</ a></center>
	</tr></td></table></center>

<?	}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.