Php login

This is a discussion on "Php login" within the PHP Forum section. This forum, and the thread "Php login are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 5th, 2006, 16:58
Junior Member
Join Date: Jul 2006
Location: RamsLand
Age: 23
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Php login

Hi All,

Im in the middle of trying to create a login function on a site im doing.

I only want the admin user to enter a password.

I have done the html page with the form -

HTML Code:
<form method="post" action="check_pass.php"> <table border="1" cellpadding="0" cellspacing="0" align="left"> <tr> <td id='ps'><b>Password:&nbsp;&nbsp;</b></td> <td><input type="password" name="password" size="12"></td> </tr> <tr> <td align="center"><input type="submit" value="Login"></td> </tr> </table> </form>


But not sure on how to write the php code. I want dont want to use a database to store the password, but know that an array or some sort can verify the password. How do i go about this??

Thanks
Reply With Quote

  #2 (permalink)  
Old Sep 14th, 2006, 22:05
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: Php login

first of all i would keep the password in a seperate file

?>
$password = "whateverpassswordyouwant";
?>

then this hopefully should work
<?
//include the password to be matched
include 'password.php';

//this is the password that the user enters
$pass = $_POST['password'];

//checks to see if password has been entered before pressing submit
//if not disoplay the form
if (!isset($_POST['password'])) {
?>
<form method="post" action="check_pass.php">
<table border="1" cellpadding="0" cellspacing="0" align="left">
<tr>
<td id='ps'><b>Password:&nbsp;&nbsp;</b></td>
<td><input type="password" name="password" size="12"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Login"></td>
</tr>
</table>
</form>
<?
}
//checks for empty field and returns error message
elseif (empty($pass)) {
echo "password required";
}
else {
//compare the 2 passwords
if (strcmp( $password,$pass ) !=0){
echo "wrong password";
//stop the script from continuing
exit;
}
//do whatever you want here after successful password
?>
Reply With Quote
Reply

Tags
php, login

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Login Jack Franklin PHP Forum 25 Oct 10th, 2007 09:27
Help with customer login mooshooh Starting Out 1 May 7th, 2007 15:46
error with login simonb PHP Forum 22 Mar 22nd, 2007 12:36
php login help Aaron1988 PHP Forum 2 Jan 25th, 2007 15:58
login script help Aaron1988 PHP Forum 2 Oct 25th, 2006 15:03


All times are GMT. The time now is 22:09.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43