Click to See Complete Forum and Search --> : PHP Authentication Script


FunkyBlueStick
12-29-2000, 06:45 PM
I'm trying to write a simple php authentication script to stop people deleting stuff out of a database with out permission.

Could someone tell me what is wrong with this script?
<html>
<body>
<form method=post action="<?php echo $PHP_SELF?>">
Name: <input type=text name=userid><br>
Password: <input type=password name=password><br>
<?php
echo ("<input type=hidden value=\"$id\" name=id>");
?>
<input type=submit>

<?php
if ($userid == "funky" and $password == "moviez")
{
header("Location: delete.php");
}
else
{
die ("You need to enter the correct Username/Password");
}
?>
</body>
</html>

When the password is wrong the script works but when it's right I get this:

Warning: Cannot add header information - headers already sent by (output started at /home/WWW/moviez/auth.php:3) in
/home/WWW/moviez/auth.php on line 14

I guess it's something to do with the header function but I can't see what!

Please help!

Thanks

(PS, auth.php is the name of the script http://www.linuxnewbie.org/ubb/smile.gif )

Sweede
12-29-2000, 09:21 PM
that is sooooo wrong...

you cannot send any text before the header() call,
your <html><body> tag is before header(),

FunkyBlueStick
12-29-2000, 09:28 PM
Thanks for replying http://www.linuxnewbie.org/ubb/smile.gif

Okay, only reason I did it was 'cos I saw it in a phpBB script but I must've taken it out of context http://www.linuxnewbie.org/ubb/frown.gif

How can I get it to go to the right page when the logon is correct then?