Home arrow PHP arrow Page 3 - A Login System for a PHP Email Application

The code: logging out and registration - PHP

We know from the previous article that the user ID is very important, in that it is used to retrieve various information from the database at various stages of the application. The login form sets this userID when you log in. It is the login system that will be the focus of this second part in a four-part series.

TABLE OF CONTENTS:
  1. A Login System for a PHP Email Application
  2. The code: form verification
  3. The code: logging out and registration
  4. The code: form handling and user profile
By: Leidago
Rating: starstarstarstarstar / 27
November 01, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Logout page. This page basically logs you out of the system and destroys any sessions that were created when you logged in. The application then returns the user to the login page.

Logout.php

<?
ob_start();
session_start();
session_unset();
session_destroy();
header("location:login.php");
?>

register.php. This code registers a new user. The fields provided in the form match those declared in the users table. See the previous article.

form

<table width="100%" border="0" cellspacing="7">
  <tr bgcolor="#FFFFFF">
    <td valign="top">&nbsp;<img src="images/registration.png"
width="661" height="130" /></td>
  </tr>
  <tr>
    <td width="89%" valign="top" colspan="2"><form
action="register.php" method="post" >
              <table width="100%" border="0" cellspacing="1"
class="block">
        <tr class="table">
          <td colspan="2">&nbsp;</td>
          </tr>
        <tr>
          <td colspan="2">*<strong>ALL</strong> fields are
required. </td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr class="td">
          <td colspan="2"><strong>User Info: </strong></td>
        </tr>
        <tr>
          <? if($err){?>
                        <td width="87%" valign="bottom"
colspan="2"><? 
                        echo "The following errors where
detected:<br>";
                        echo "<font color = "#ff000
">$errmsg</font><br>"; ?>  </td>
      <? }?>
                 </tr>
        <tr>
          <td width="29%">Login name </td>
          <td width="71%"><input name="uname" type="text"
id="uname" size="60" /></td>
        </tr>
        <tr>
          <td>Login Password </td>
          <td><input name="upass" type="text" id="upass"
size="60" /></td>
        </tr>
                        <tr>
          <td>Email Address </td>
          <td><input name="email" type="text" id="email"
size="60" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr class="td">
          <td colspan="2"><strong>Logon Info: </strong></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>RemoteUsername </td>
          <td><input name="remuser" type="text" id="remuser"
size="60" /></td>
        </tr>
        <tr>
          <td>Remote Password </td>
          <td><input name="rempass" type="text" id="rempass"
size="60" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr class="td">
          <td colspan="2"><strong>Server Info: </strong> </td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>Incoming Mail Server: </td>
          <td><input name="pop3" type="text" id="pop3"
size="60" /></td>
        </tr>
        <tr>
          <td>Outgoing Mail Server: </td>
          <td><input name="smtp" type="text" id="smtp"
size="60" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="submit" value="Register
me now!" /></td>
        </tr>
      </table>
              </form>    </td>
  </tr>
  <tr>
    <td colspan="2"><div align="center">Copyright 2005 </div></td>
  </tr>
</table>



 
 
>>> More PHP Articles          >>> More By Leidago
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: