Error
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.
  • JHTMLicon not supported. File not found.

//may

Simple Login Script using associative array
Wednesday, 14 July 2010 03:37
// description of your code here


//Simple Login Script using associative array.

//You may modify the codes and use $_POST['FORM_FIELD_DATA'] for your web-page.
//You may spice-up the codes with more form field validation & security features.

//$user_name=$_POST['user_name'];
//$password=$_POST['password'];

$test_user_name = 'michelle_smith'; //for testing purpose only
$test_password = 'msmith321'; //for testing purpose only
$user_name = $test_user_name;
$password = $test_password;

// here user_name is key and password is the value of an array..
// website owner has to add new user/site member manually in $login_array

$login_array = array(
'user_name' => 'password',
'alex_duff' => 'alx321',
'xena78' => 'xena321',
'dela_pena' => 'delp321',
'shawn_1981' => 'shw81',
'michelle_smith' => 'msmith321');

ksort ($login_array);
reset($login_array);
if (isset($login_array[$user_name]))
{
$pass_check = $login_array[$user_name];
if ($password === $pass_check)
{
echo "Welcome, $user_name!\n
"; //may redirect to specific webpage.
}
else
{
echo "Please try again!"; //may redirect to Error page.
}
}
else
{
echo "Please register with us. Thanks!"; //may redirect to registration page.
exit();

}
echo("\n
");
echo 'Thanks to Thies C. Arntzen, Stig Bakken, Shane Caraveo, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski for wonderful PHP!';

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/92MXATPdFPQ/11885

 


Taxonomy by Zaragoza Online