Log-in - Member functions - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Log-in - Member functions (/showthread.php?tid=20370) Pages:
1
2
|
RE: Log-in - Member functions - Billy Mays - 07-11-2011 Theres a few codes that can help you Mate Strategy Used behind the Login System: Here we shall use 5 files for making the whole system. config.php: The main file for holding the information related to the admin MySQL table. We shall discuss in brief how to create the table. For information do check the MySQL posts. admin.php: For administrative functions. It will redirect to login.php if not authorized already; login.php: A webpage for displaying form of login. It will submit the form to check_login.php where it will be processed further; check_login.php: A PHP script to check the login details from the MySQL Table. If successfully matched, then it will register the Session, else will redirect back to the login.php file with error message; logout.php: It will delete the session, and will redirect back to login.php file with success message; #1: Setting up the MySQL Table: We shall use a MySQL table like this for storing administrator information: Code: id user_name user_pass Basically we shall encrypt the password inside the table. Just for the demonstration I have showed the passwords above… Now create a Database and inside it create a table login_admin with the following MySQL query command: Code: CREATE TABLE login_admin Now insert the two user information inside the table with the following command: Code: INSERT INTO login_admin (user_name, user_pass) Now your MySQL table is ready for use! #2: Setting up the config.php file: As mentioned before, it just contains all the necessary MySQL Database connection information. Here is the code for this file: Code: <?php Just save this file with the above codes. #3: Code behind the login.php File: It shows up the login form and moves it to check_login for further processing! Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> #4: Code Behind the check_login.php file: Code: <?php As you can see it registers $_SESSION['name'] superglobal variable along with session_register and then redirects to admin.php. Now lets see what the admin.php file has to protect it from unauthorized use! Also note that if username and password do not match, then it redirects back to the login.php file with an error $msg. #5: Code behind admin.php file: Code: <?php I have put comments every where! So you will be able to easily understand the code! Basically, here you need to be creative to put the admin contents properly! What ever it is, it will only be shown to authorized users. Also we have set a constant ADMIN to fetch the username from the super global variable $_SESSION[‘name’] and we can echo it where ever we want! #6: Logging out with logout.php It is used to destroy the current session. It is very simple! Code: <?php Save the file with the above code and you are done! RE: Log-in - Member functions - notLuke - 07-12-2011 Whatever you're looking for, W3Schools probably has it. w3.com RE: Log-in - Member functions - Relapse - 07-12-2011 Did you get all the stuff your looking for? RE: Log-in - Member functions - Carbon Host - 08-02-2011 i was going to do this to but i never finished it RE: Log-in - Member functions - Closed Account - 08-06-2011 Even Try Googling Article http://google.com RE: Log-in - Member functions - RaZoR - 09-30-2011 http://www.ineedtutorials.com/code/php/c...p-tutorial i made as this tutorial but it doesnt work only white screen. if some one know please help me RE: Log-in - Member functions - cuonic - 11-30-2011 https://github.com/cuonic/Auth |