Start register code. Register.php
<form method=post action=register.php?action=register name=s><table><tr><td>Username:</td><td><input type=text name=user></td></tr><tr><td>Email:</td><td><input type=text name=email></td></tr><tr><td>Pass:</td><td><input type=password name=pass></td></tr><tr><td>Verify Pass:</td><td><input type=password name=vpass></td></tr><tr><td colspan=2 align=center><input type=submit value=Register></td></tr></table></form><?php//Login to your database. Make the fields of course..mysql_connect("localhost","user","pass");mysql_select_db("database");//end//if registering, check fields.if ($action == register) { if (!$user || !$pass || !$email || !$vpass) { print "You must fill out all fields."; exit; }$dupe1 = mysql_num_rows(mysql_query("select * from table where user='$user'")); if ($dupe1 > 0) { print "Someone already has that username."; exit; }$dupe2 = mysql_num_rows(mysql_query("select * from table where email='$email'")); if ($dupe2 > 0) { print "Someone already has that email."; exit; }//check if passwords are the same if ($pass != $vpass) { print "The passwords do not match."; exit; }//end//insertmysql_query("insert into table (user, email, pass) values('$user','$email','$pass')");print "You are now registered. Login.";}?>
Now that you are done with register, make the login. Login.php <form method=post action=Login.php?action=login><table><tr><td>Email:</td><td><input type=text name=email></td></tr><tr><td>Pass:</td><td><input type=password name=pass></td></tr><tr><td colspan=2 align=center><input type=submit value=Login></td></tr></form></table><?phpif($action==login){//checkif (!$email || !$pass) { print "Please fill out all fields."; exit;}$logres = mysql_num_rows(mysql_query("select * from table where user='$email' and pass='$pass'"));if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit;} else {//logged in, register the session.. session_register("email"); session_register("pass"); print "You are now logged in..";}}?>
Now, this is members.php, it checks if the session is registered or not.. <?phpif (!session_is_registered("email") || !session_is_registered("pass")) { print "You need to login to view this page!! "; exit;}print "Content here";?>
Ok, we are done, if you do not know how to do the mysql for the pages, here is the sql code: CREATE TABLE `table` ( `id` int(5) NOT NULL auto_increment, `user` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '', `pass` varchar(255) NOT NULL default '', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=1;
Thats it!