not completed yet

PART 1

Lets create the table structure we need to register our users.


CREATE TABLE members (
member_id int(10) unsigned NOT NULL auto_increment,
first_name varchar(100) NOT NULL,
last_name varchar(100) NOT NULL,
email_address varchar(100) NOT NULL,
date_registered datetime NOT NULL,
last_accessed datetime NOT NULL,
password char(32) NOT NULL,
profile_name varchar(30) NOT NULL,
PRIMARY KEY (member_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;



copy and paste the sql into phpMysqladmin sql window and execute it. You would create a table members in your database.


PART 2

copy and paste the following code into a php file called register.php. If anybody wants to register with your site they have to access through the site.

http://www.yourserver.com/register.php




if($_POST['submit_registration']) {

// enter your database info here -----

$db_name = ; // find your db name and add it over here
$user = ; // find your db username and add it here
$password = ; // add your password to the db here


// check user input and filter them
$firstname = mysql_real_escape_string($_POST['fname']);
$lastname = mysql_real_escape_string($_POST['lname']);
$profile = mysql_real_escape_string($_POST['pname']);
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$cpassword = mysql_real_escape_string($_POST['cpassword']);

if(!$firstname || !$lastname || !$profile || !$email || !$password || !$cpassword) {

echo "All fields are required, please fill them";
}
else {

// ------------------- DON'T TOUCH BELOW NOW-----------------
$db_link = @mysql_connect("localhost",$user,$password);

if($db_link)
@mysql_select_db($db_name);
else {
echo "Error in your db connection, check db_name, user_name and password";
exit;
}

if(!mysql_query("select member_id from members where email='$email' or profile_name='$profile')) {
$has_success = @mysql_query("insert into members values(null,'$firstname','$lastname','$email',now(),now(),md5($password),'$profile')");
if($has_success)
echo "Your registration was successful";
}
else
echo "The profile name / email is already registered");
}
else {
// display registration form
?>




<form method="post">
<table cellpadding="0" cellspacing="0">
<tbody><tr>
<td>First Name</td>
<td></td>
<td><input name="fname" maxlength="255" size="20" value="" type="text"></td>
</tr>
<tr>
<td>Last Name</td>
<td></td>
<td><input name="lname" maxlength="255" size="20" value="" type="text"></td>
</tr>
<tr>
<td>Email</td>
<td></td>
<td><input name="email" maxlength="255" size="20" value="" type="text"></td>
</tr>
<tr>
<td>Profile Name</td>
<td></td>
<td><input name="pname" maxlength="255" size="20" value="" type="text"></td>
</tr>
<tr>
<td>Password</td>
<td></td>
<td><input name="password" maxlength="255" size="20" value="" type="text"></td>
</tr>
<tr>
<td>Confirm Password</td>
<td></td>
<td><input name="cpassword" maxlength="255" size="20" value="" type="text"></td>
</tr>
</tbody></table>
</form>





}

0 comments



Some Links (off programming)