One More

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prithvim
Forum Newbie
Posts: 16
Joined: Fri Apr 16, 2004 3:34 pm
Location: India
Contact:

One More

Post by prithvim »

i have got one more problem. cant make out where the mistake is !! :?:
here are the two scripts that i used:

Code: Select all

<html>
<head>
<title>User Login</title>
</head>
<body>
<div>
<form action="loginuser.php" method="post">
<b>UserID: </b><input type="text" name="userid" length="8" size="8"><br>
<b>Password: </b><input type="password" name="password" length="8" size="8"><br><br>
<input type="reset" value="Reset">&nbsp;&nbsp;
<input type="submit" value="Login">
</div>
</body>
</html>
and:

Code: Select all

<?php

session_start();

if($fp=fopen("$_POST&#1111;userid].txt","r"))
	&#123;
		$check1=fgets($fp);
		$check2=fgets($fp);
		$name=fgets($fp);
		fclose($fp);

		if($check2==$_POST&#1111;password])
			&#123;
				$_SESSION&#1111;'name']=$name;
				print("You are now logged in as <b>$_POST&#1111;userid]</b>.");
			&#125;
		else
			&#123;
				die("Invalid password.");
			&#125;
	&#125;
else
	&#123;
		die("UserID does not exist.");
	&#125;

?>
it says invalid password though i have typed the correct password !!
no matter what i change..it is not workin.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

change

Code: Select all

if($check2==$_POST&#1111;password])
to

Code: Select all

if($check2==$_POST&#1111;'password'])
prithvim
Forum Newbie
Posts: 16
Joined: Fri Apr 16, 2004 3:34 pm
Location: India
Contact:

Post by prithvim »

nope it is not working.
i had already tried that.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

well.. that is an quasi-error anyway. Uhm... tried using trim($check2)?
prithvim
Forum Newbie
Posts: 16
Joined: Fri Apr 16, 2004 3:34 pm
Location: India
Contact:

Post by prithvim »

but there is only the password in one line
that is the way i wrote to the text file !!
and also when i echo @check2 to the screen..it comes out exactly same as the password entered !!
Post Reply