List Info

Thread: note 78396 added to language.types.array




note 78396 added to language.types.array
user name
2007-10-10 04:14:20
<?php

//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<br>"; //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<br>");
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!';

?>
----
Server IP: 69.147.83.197
Probable Submitter: 208.72.122.102
----
Manual Page -- http://www.php.net/manual/en/language.types.array.php
Edit        -- https://master
.php.net/note/edit/78396
Del: integrated  -- h
ttps://master.php.net/note/delete/78396/integrated
Del: useless     -- http
s://master.php.net/note/delete/78396/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78396/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78396/spam
Del: non-english -- 
https://master.php.net/note/delete/78396/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78396/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78396
Reject      -- https://mast
er.php.net/note/reject/78396
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )