|
|
#1 (permalink) |
|
Senior Member
Join Date: Nov 2006
Posts: 119
|
Hey!
First of all, the MySQL code. Code:
CREATE TABLE `members` ( `id` int(4) NOT NULL auto_increment, `username` varchar(65) NOT NULL default '', `password` varchar(65) NOT NULL default '', PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; INSERT INTO `members` VALUES (1, 'Username', 'Password'); main_login.php [html]<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table>[/html] checklogin.php PHP Code:
login_success.php PHP Code:
Logout.php PHP Code:
FOR PHP5 USERS -> checklogin.php PHP Code:
|
|
|
|
|
|
#2 (permalink) |
|
co-admin
Join Date: Oct 2006
Location: Belgium
Posts: 666
|
Good script ... but what do you have to set like on top of every page?
(I know... but others, who don't know PHP that well won't. Please add in your topic .)Also, you should use the PHP-tags, instead of the CODE-tags: [ php] [/ php] (without the spaces) |
|
|
|
|
|
#5 (permalink) |
|
co-admin
Join Date: Oct 2006
Location: Belgium
Posts: 666
|
Here is a demo (hosted by me!):
http://styx.freehostia.com/login/main_login.php ----> Username: demo ----> Password: demo Note, password isn't encrypted ... and the input field for the password is not hidden. If you want to make it hidden (******) you have to do this: Chnage the following line in main_login.php: [HTML]<input name="mypassword" type="text" id="mypassword">[/HTML] Into this: [HTML]<input name="mypassword" type="password" id="mypassword">[/HTML] An example of this is here: http://styx.freehostia.com/login/main_login2.php ----> Username: demo ----> Password: demo |
|
|
|
|
|
#9 (permalink) |
|
Member
Join Date: Nov 2006
Posts: 47
|
To check if a user is logged in or not, you need to put this code on the top of the page:
PHP Code:
|
|
|
|