1. Computing

PHP Login Script

By , About.com Guide

3 of 7

Registration Page 2
 <?php 
 } 
else { ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table border="0">
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="60">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="10">
</td></tr>
<tr><td>Confirm Password:</td><td>
<input type="password" name="pass2" maxlength="10">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit"
value="Register"></th></tr> </table>
</form>
<?php
} ?>
Registration Full Code

Basically what this does is check to see if the form has been submitted. If it has been submitted it checks to make sure that the data is all OK (passwords match, username isn't in use) as documented in the code. If everything is OK it adds the user to the database, if not it returns the appropriate error.

If the form has not been submitted, they are shown the registration form, which collects the username and password.

Related Video
Basic PHP Syntax
Using PHP With HTML
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. Step By Steps
  5. Login PHP Script - Login PHP - Free Login PHP Script

©2013 About.com. All rights reserved.