Creating a simple PHP/MySQL login script - 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: Creating a simple PHP/MySQL login script (/showthread.php?tid=6405) Pages:
1
2
|
Creating a simple PHP/MySQL login script - ndee - 04-20-2010 In this tutorial I'll be teaching you how to create a simple PHP login script, it is not very complicated, all this does is just give you an idea of how a login script works. You will need a MySQL database. Creating the table The first step is obviously creating the table, so let's get right to it. I'll only use 2 fields, "username" and "pw". CREATE TABLE tns_users (username VARCHAR(60), pw VARCHAR(60)) Run that SQL query on any of your databases and it will create a table called: tns_users with 2 fields, "username" and "pw". Creating the user(s) Now it's time we create our user: Code: INSERT INTO tns_users (username, pw) VALUES ('TNS', 'thenopslide') Run that SQL query on the same database where you ran the first one, you should now have a new user in your table, with TNS as a username and thenopslide as password. Login Page Now that the database work is done, it's time we create our HTML/PHP files. Let us start with the Login Page: Code: <form action="check.php" method="post"> Check.php Now that we've successfully made a working form, it's time we create the check.php file that will check the username and password. PHP Code: <?php That's pretty much it, be sure to replace some of the database information with your own. BEWARE: This script is NOT secure and should NOT be used on a website. The script was just to give you a general idea about how a login script works. RE: Creating a simple PHP/MySQL login script - Support - 04-20-2010 *cough*Injectable*cough* Otherwise, nice tutorial. Have a look at UserCake by the way. RE: Creating a simple PHP/MySQL login script - ndee - 04-20-2010 Obviously injectable. Like I said at the end of the tutorial, the script is NOT secure and should NOT be used on a website. Thanks for reading. RE: Creating a simple PHP/MySQL login script - Unspoken - 04-22-2010 Nice share great job RE: Creating a simple PHP/MySQL login script - Tierney - 04-23-2010 Thanks. I'm not very good with MySQL databases yet (and their integration with PHP), and this helped me out a bit with them. RE: Creating a simple PHP/MySQL login script - Streeeam - 04-24-2010 I use something like this, but my script is way more secure. Great guide mate. RE: Creating a simple PHP/MySQL login script - Яichie - 04-24-2010 I'll use this to start my own CMS, Although I will not use this exact code, I will use parts of this. Thank you RE: Creating a simple PHP/MySQL login script - JesusOfSuburbia - 04-26-2010 Thank's. Simple but Usefull RE: Creating a simple PHP/MySQL login script - Omniscient - 04-27-2010 Always good to teach good security habits even for beginners. As a matter of fact...especially for beginners. Instead of stripslashes I recommend mysql_real_escape_string(). http://us.php.net/manual/en/function.mysql-real-escape-string.php RE: Creating a simple PHP/MySQL login script - NathanE - 12-27-2010 very nice tutorial mate. thanks for sharing. |