WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : basic user validation
Categories : PHP, Authentication Click here to Update Your Picture
Riccho Blakey
Date : Jul 11th 2005
Grade : 1 of 5 (graded 2 times)
Viewed : 7014
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Riccho Blakey
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php # Script Hgram_Fam_Registration.php

require_once('mysql_connect.php');//Connect to the database.

if(isset($_POST['submit'])) { //Handle the registration form.
   
    //Validate the username, first_name, last_name, password, email, city, state, zip and picture for member registration.

    //Check for a the first_name

   
if (eregi("^[[:alpha:].' -]{2,15}$", stripslashes(trim($_POST['first_name'])))){
       
$fn = $_POST['first_name'];
    }else{
       
$fn = FALSE;
        echo
'<p><font color="red">Please enter your first name!</font></p>';
    }

   
//Check for a the last_name

   
if (eregi("^[[:alpha:].' -]{2,15}$", stripslashes(trim($_POST['last_name'])))){
       
$ln = $_POST['last_name'];
    }else{
       
$ln = FALSE;
        echo
'<p><font color="red">Please enter your last name!</font></p>';
    }
   
   
//Check for a the email address

    //if (eregi("^[[:alnum:]]{a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$",
    //stripslashes(trim($_POST['email'])))){
       
$em = $_POST['email'];
   
//}else{
        //$em = FALSE;
        //echo '<p><font color="red">Please enter your email address!</font></p>';
    //}
        //Check for a the username
       
   
if (eregi("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))){
       
$un = $_POST['username'];
    }else{
       
$un = FALSE;
        echo
'<p><font color="red">Please enter a valid username!</font></p>';
    }
   
   
//Check that the passwords are entered and match each other.
   
   
if (eregi("^[[:alnum:]]{4,20}$", stripslashes(trim($_POST['password1'])))){
          if((
$_POST['password1']) == ($_POST['password2'])){
           
$pw = $_POST['password1'];
        }else{
           
$pw = FALSE;
            echo
'<p><font color="red">Please try again!</font></p>';
        }
    } else {
       
$pw = FALSE;
        echo
'<p><font color="red">Please try again!</font></p>';
    }
   
   
//Check for a the the city
   
   
if (!empty($_POST['city'])){
       
$city = $_POST['city'];
    }else{
       
$city = FALSE;
        echo
'<p><font color="red">Please try again!</font></p>';
    }

   
//Check for a the state
   
   
if (!empty($_POST['state'])){
       
$state = $_POST['state'];
    }else{
       
$state = FALSE;
        echo
'<p><font color="red">Please enterState!</font></p>';
    }

       
//Check for a the zip code
   
   
if (!empty($_POST['zip'])){
       
$zip = $_POST['zip'];
    }else{
       
$zip = FALSE;
        echo
'<p><font color="red">Please enter your zip</font></p>';
    }
   
//Check the if the file moved over.
   
if (is_uploaded_file($_FILES['image']['tmp_name'])){
        if(
move_uploaded_file($_FILES['image']['tmp_name'],
       
"../{$_FILES['image']['name']}")) {//Move the file over.
         
             //echo '<p> The file has been uploaded!</p>';
       
} else {//Could not move the file over.
           
echo '<p><font color="red"> The file could not be moved.</font></p>';
           
$i = '';
            }
           
$i = $_FILES['image']['name'];
        }else{
           
$i = '';
            echo
'<p><font color="red">Please try again!</font></p>';
       
        }

   
        if (
$un && $pw && $fn && $ln && $em && $city && $state && $zip && $i) { //If everything is ok
       
header("Location: show.php");
        exit();
            }
       
        }
//End of main Submit conditional.
       
?><html>
<head>
<CENTER>
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method=post enctype="multipart/form-data">
    <fieldset>
    <TABLE border=3 cellspacing=0 cellpadding=2 bgcolor="#990000">
     <tr>
<TD>
<font face="tahoma">Username:</font>
</TD>
<TD>
<input type=text name="username" size=10,1 maxlength=10
>
</TD></tr>   
<tr>
<TD>
<font face="tahoma">First Name:</font>
</TD>
<TD>
<input type=text name="first_name" size=20,1 maxlength=20>
</TD></tr>
<tr>
<TD>
<font face="tahoma">Last Name:</font>
</TD>
<TD>
<input type=text name="last_name" size=20,1 maxlength=20>
</TD></tr>
<tr valign=baseline>
<TD>
<font face="tahoma">Email Address:</font>
</TD>
<TD>
<input type=text name="email" size=30,1 maxlength=40>
</TD>
</tr>
<tr>
<TD>
<font face="tahoma">Password:</font>
</TD>
<TD>
<input type=text name="password1" size=10,1 maxlength=10>
</TD></tr>
<tr>
<TD>
<font face="tahoma">Confirm Password:</font>
</TD>
<TD>
<input type=text name="password2" size=10,1 maxlength=10>
</TD></tr>
<tr>
<TD>
<font face="tahoma">City:</font>
</TD>
<TD>
<input type=text name="city" size=25,1 maxlength=35>
</TD></tr>
<tr>
<TD>
<font face="tahoma">State:</font>
</TD>
<TD>
<input type=text name="state" size=2,1 maxlength=2>
</TD></tr>
<tr>
<TD>
<font face="tahoma">Zip Code:</font>
</TD>
<TD>
<input type=text name="zip" size=5,1 maxlength=5>
</TD></tr>
</TABLE>


<center>
      <p>
        <input type="file" name="image">
      </p>
      <p></p>
      <p></p>
      <p></p>
      <p><input type="submit" name ="submit" value="Continue">
</p></center></FORM>
</center></body>
</html>



Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
Function to remember password
Categories : PHP, Authentication, Personalization and Membership
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
Authorize Me! An authentication script.
Categories : MySQL, Databases, Authentication, PHP
Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
Import the yahoo address book.
Categories : PHP, CURL, Authentication
Simple and fast user authentication
Categories : PHP, PHP Classes, Authentication
Is there some possibility to link a database to an htaccess file, so that instead of having a passwd file you would have a database with DES-crypted password and username fields?
Categories : Authentication, PHP, General SQL, Databases
Authentication HTTP protocol POST
Categories : Authentication, HTTP, PHP
Full membership authentication system.
Categories : Authentication, MySQL, PHP, Databases
A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page.
Categories : PHP, Sessions, Security, Authentication
Implementing a "Members ONLY" area
Categories : PHP, MySQL, Databases, Authentication
AUTH (.htaccess style) - a login system that uses PostgreSQL.
Categories : PHP, Authentication, Databases, PostgreSQL
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security