Page 1 of 1

One More

Posted: Fri Apr 16, 2004 6:58 pm
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.

Posted: Fri Apr 16, 2004 6:59 pm
by feyd
change

Code: Select all

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

Code: Select all

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

Posted: Fri Apr 16, 2004 7:06 pm
by prithvim
nope it is not working.
i had already tried that.

Posted: Fri Apr 16, 2004 7:15 pm
by feyd
well.. that is an quasi-error anyway. Uhm... tried using trim($check2)?

Posted: Sun Apr 18, 2004 8:19 am
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 !!