Enhanced register page.

Post all your tuts or request for tuts here.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Enhanced register page.

Post by Torniquet »

As promised guys,

EDIT~~~

ok after all that work... i cant embed the file ¬¬ halls sort it out boy :p

hopfully this link will redirect you lol.

[vimeo]http://vimeo.com/5931700[/vimeo]

is my 1st tutorial. Im not the greatest at explaining things. but have done my best. Source code for the 'php' parsing script and the 'activation' page is as follows.

register.php...

Code: Select all

<?php


if (isset ($_POST['username'])){
	
	$username = $_POST['username'];
	$email1 = $_POST['email1'];
	$email2 = $_POST['email2'];
	$pass1 = $_POST['pass1'];
	$pass2 = $_POST['pass2'];
    $humancheck = $_POST['humancheck'];
	
	$username = stripslashes($username);
	$email1 = stripslashes($email1);
	$email2 = stripslashes($email2);
	$pass1 = stripslashes($pass1);
	$pass2 = stripslashes($pass2);
	
	$username = strip_tags($username);
	$email1 = strip_tags($email1);
	$email2 = strip_tags($email2);
	$pass1 = strip_tags($pass1);
	$pass2 = strip_tags($pass2);
	
	include_once "*connection script name/location*";
	$emailChecker = mysql_real_escape_string($email1);
	$emailChecker = eregi_replace("`", "", $emailChecker);
	$usernameChecker = mysql_real_escape_string($username);
	$usernameChecker = eregi_replace("`", "", $usernameChecker);
	
	
	$sql_email_check = mysql_query("SELECT email FROM *table name* WHERE email='$emailChecker'");
	$email_check = mysql_num_rows($sql_email_check); 
	$sql_username_check = mysql_query("SELECT email FROM *table name* WHERE username='$usernameChecker'");
	$username_check = mysql_num_rows($sql_username_check); 
	 
	if ((!$username) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) { 
	
	$errorMsg = "ERROR: Missing Vital Information:<br /><br />";
	
	if(!$username){ 
	   $errorMsg .= " * Username<br />";
	} 
	
	if(!$pass1){ 
	   $errorMsg .= " * Password<br />";
	} 
	
	if(!$pass2){ 
	   $errorMsg .= " * Confirm Password<br />";
	} 
	
	if(!$email1){ 
	   $errorMsg .= " * Email<br />";
	} 
	
	if(!$email2){ 
	   $errorMsg .= ' * Confirm Email<br />';
	   
	}
	
	}
	
	else if ($email1 != $email2) {
			  $errorMsg = 'ERROR: Email Fields Mis Matched.<br />';
	} else if ($pass1 != $pass2) {
			  $errorMsg = 'ERROR: Password Fields Mis Matched.<br />';
	} else if ($humancheck != "") {
			 $errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human.<br />';		 
	} else if ($email_check > 0){ 
			  $errorMsg = "<u>ERROR:</u><br />Your Email Is Already Registered.<br />";
	} else if ($username_check > 0){
		$errorMsg = "<U>ERROR:</u>Username Already In Use.<br>";
	} else {
		
		$username = mysql_real_escape_string($username);
		$pass1 = mysql_real_escape_string($pass1);
		$email1 = mysql_real_escape_string($email1);
		
		$username = eregi_replace("`", "", $username);
		$pass1 = eregi_replace("`", "", $pass1);
		$email1 = eregi_replace("`", "", $email1);
		
		$db_password = md5($pass1);
		
		$sql = mysql_query("INSERT INTO *table name* (username, password, email, sign_up_date) 
	 VALUES('$username','$db_password','$email1', now())")  
	 or die (mysql_error());
	 
	 $id = mysql_insert_id();
	 
	 mkdir("members/$id", 0755);
		
		
	$to = "$email1";
									   
  $from = "admin@*your domain*.com";
  $subject = "Complete Netrix Network registration";
  //Begin HTML Email Message
  $message = "Hi $username,

 Complete this step to activate your login identity at *your game*.

 Click the line below to activate when ready.

 http://www.*your domain*.com/activation.php?id=$id&sequence=$db_password
 If the URL above is not an active link, please copy and paste it into your browser address bar

 Login after successful activation using your:  
 Username: $username
 Password: $pass1

 See you on the site!
 admin@*your domain*.com";
 //end of message
  $headers  = "From: $from\r\n";
  $headers .= "Content-type: text\r\n";

  mail($to, $subject, $message, $headers);
  
 $msgToUser = "<h2>One Last Step - Activate through Email</h2><h4>OK $username, one last step to verify your email identity:</h4><br />
 In a moment you will be sent an Activation link to your email address.<br /><br />
 <br />
 <strong><font color=\"#990000\">VERY IMPORTANT:</font></strong> 
 If you check your email with your host providers default email application, there may be issues with seeing the email contents.  If this happens to you and you cannot read the message to activate, download the file and open using a text editor. If you still cannot see the activation link, contact site admin and briefly discuss the issue.<br /><br />
 ";


 include_once 'msgToUser.php'; 

 exit();
 
	}

}else{
	 $errorMsg = "Fields marked with an [ * ] are required";
      $username = "";
	  $pass1 = "";
	  $pass2 = "";
	  $email1 = "";
	  $email2 = "";
	  

}

?>

activation.php...

Code: Select all

<?php

if ($_GET['id'] != "") {
	
	include_once "*connection script name/location*";

    $id = $_GET['id']; 
    $hashpass = $_GET['sequence']; 

    $id  = mysql_real_escape_string($id );
    $id = eregi_replace("`", "", $id);

    $hashpass = mysql_real_escape_string($hashpass);
    $hashpass = eregi_replace("`", "", $hashpass);

    $sql = mysql_query("UPDATE *table name* SET email_activated='1' WHERE id='$id' AND password='$hashpass'"); 

    $sql_doublecheck = mysql_query("SELECT * FROM *table name* WHERE id='$id' AND password='$hashpass' AND email_activated='1'"); 
    $doublecheck = mysql_num_rows($sql_doublecheck); 

    if($doublecheck == 0){ 
        $msgToUser = "<br /><br /><h3><strong><font color=red>Your account could not be activated!</font></strong><h3><br />
        <br />
        Please email site administrator and request manual activation.
        "; 
    include 'msgToUser.php'; 
	exit();
    } elseif ($doublecheck > 0) { 

        $msgToUser = "<br /><br /><h3><font color=\"#0066CC\"><strong>Your account has been activated! <br /><br />
        Return to the main page to log in.</strong></font></h3>";
	
    include 'msgToUser.php'; 
	exit();
} 

}

print "Essential data from the activation URL is missing! Close your browser, go back to your email inbox, and please use the full URL supplied in the activation link we sent you.<br />
<br />
admin@*your domain*.com
";


?>
I hope all is ok for you and you can understand it... got any questions, this is the place to ask. :)

In a few i will be posting the addittions i done after the video.

LUBS xxx
New Site Coming Soon! Stay tuned :D
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Enhanced register page.

Post by Torniquet »

Ok as for the additions. They are as follows...

1st was a check to make sure the password and the username length was more than 3 characters long. which on my form means your lenths need to be between 4 and 20 chars for a username and 4 and 16 for a password length.

the code is as follows...

Code: Select all

else if (strlen($username) <= 3){
		$errorMsg = 'ERROR: Username length to short. <br />';
	} else if (strlen($pass1) <= 3){
		$errorMsg = 'ERROR: Password length to short. <br />';
	}
this code can go any where really. depends where you want it to be checked. I placed mine before the check to see if both emails are the same.

E.G

Code: Select all

else if ($email1 != $email2) {
			  $errorMsg = 'ERROR: Email Fields Mis Matched.<br />';
	}

The second addition I made to my script was a check to make sure the email contained 2 specific characters. the period sign and the @ simbol. if the email didnt contain atleast one of each of these symbols then it would return an invalid email message.

Again this can be placed anywhere in the parsing script.

I placed mine above the character length check (addition 1)

Code: Select all

else if (
			!strpos($email1,"@")||
			!strpos($email1,".")
			){
		$errorMsg = 'ERROR: Invalid Email Address.<b />';
	}

Any questions ask away :D

LUBS xxx
New Site Coming Soon! Stay tuned :D
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Enhanced register page.

Post by hallsofvallhalla »

i only watched the first 4 minutes due to time restrictions, I am real busy but looks great so far.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Enhanced register page.

Post by Torniquet »

any chance you can sort my account out so i can embed.... or you try to embed it or somthing please :)
New Site Coming Soon! Stay tuned :D
User avatar
Noctrine
Posts: 928
Joined: Thu Apr 23, 2009 9:57 pm

Re: Enhanced register page.

Post by Noctrine »

Done
Jesse Dorsey
ProjectANI - Lead Developer Person
http://about.me/jessedorsey
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Enhanced register page.

Post by darspire »

im gettin a lot of errors. maybe just me?

register.php page is blank when i type in localhost/tutorial/register.php
activation.php page says error on line 3. like i said. maybe just me?
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Enhanced register page.

Post by Torniquet »

I have never tried it on a local host. what kind of errors are you getting??

the script in there is exactly what i used minus a few bits of info like domain name the include_once connection script.

I dont see why it wouldnt work :s
New Site Coming Soon! Stay tuned :D
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Enhanced register page.

Post by darspire »

idk on the localhost/tutorial/register.php page theres nothing there
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Enhanced register page.

Post by Torniquet »

oh ok. yeah i had the same problem to start with.

make sure you have semi colons where you need them. it will most likley be that or your havnt got all the closing brackets in the right place.
New Site Coming Soon! Stay tuned :D
darspire
Posts: 194
Joined: Sat Jul 25, 2009 9:21 pm

Re: Enhanced register page.

Post by darspire »

i copied and pasted your code
if you love something, let it go.
if it doesnt return.....hunt it down and kill it.
Post Reply

Return to “Tutorials”