tags:

views:

52

answers:

1

It gives the wrong result. I use Dreamweaver and i just started to learn PHP i find it very hard to debug.

</html>
<head>
<title>Login Form</title>
</head>

<body>
<fieldset><legend>Login</legend>
<form action="login.php" method="post" /><br/>
Username<input type="text" name="User" /><br/>
Password<input type="password" name="Pass" /><br/>
<input type="submit" value="submit" />
<input type="reset" value="clear"/>
</form>
</body>
</html>





<?php
$_user=$_POST["user"];
$_pass=$_POST["pass"];
if(($user=="hamza")&&($pass=="2"))
echo "Access Granted";
else echo "access denied";
?>
+3  A: 
if(($user=="hamza")&&($pass=="2"))

Should be

if($_user=="hamza" && $_pass=="2")

And

$_user=$_POST["user"];
$_pass=$_POST["pass"];

Should be:

$_user=$_POST["User"];
$_pass=$_POST["Pass"];

Case matters!

To be able to see errors like these at a glance: enable display_errors locally (not on a live server) and set error_reporting to E_ALL in php.ini. That would have given you the notice that the $user & $pass variables did not exist.

Wrikken
Now *that* was easy. +1
BoltClock
it still didn't work. the same error.
Rookie9
if u can please try it by just copying and pasting and running the script.
Rookie9
Ah, there was another error, edited answer accordingly.
Wrikken
WOW Case matters! will always remember. :) thumbs up for u
Rookie9