Friday, June 6, 2008

Login form


Hey so this is my first tutorial, this isn't a step by step tutorial as you can see i have just wrote a login script and explained what i was doing as i go along if it is a success i will write a register tutorial as well. Thanks KiNgY
PHP:
The session_start(); function is important and needs to go at the start of each page you want logged in members to access.The include() function just includes my db_connect script which allows me access to my database.
PHP:
This i feel is rather self explanatory, the value of $id depends on which fields of data are missing, i will use $id further down the script to display certain error messages.If the required data is entered it will be queried against my database and if there is a row with username $user and password $pass the login is a success and the session username is set and the user is forwarded onto a different page in this case logged_in.php.HTML for the login formthere is also some php in here for displaying error messages


PHP:
'' && $id<='3'){ echo ""; }if($id=='5'){ echo ""; }?>
User Login
Please fill in missing fields (*)
Sorry but your login details where incorrect

PHP:
* "; }?>Username:

PHP:
* "; }?>Password:
LinksIf you would like to see the completed code please visit here:Full source codeThanks again KiNgY

No comments: