HoTDaWg Posted December 29, 2006 Share Posted December 29, 2006 its strange, its either when you hit submit the header location goes to Yahoo! or it says access denied. here is my script:[code]<?php$submittedusername = $_REQUEST['submittedusername'];$submittedpassword = $_REQUEST['submittedpassword'];$username[0] = "user1";$username[1] = "user2";$password="pass";if ($submittedusername=='$username' && $submittedpassword=='$password'){header("Location:http://www.yahoo.ca/");} else {echo "Access Denied";}?>[/code]and the html part is:[code]<html><head><title>Log-in</title><head></head><body><form name="login" action="login.php">username: <input name="submittedusername" type="text" /><br />password: <input name="submittedpassword" type="text" /><br /><input type="submit" value="Submit!" /></form></body></html>[/code]where have i gone wrong?any help would greatly be appreciated. thanks.HoTDaWg Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/ Share on other sites More sharing options...
corbin Posted December 29, 2006 Share Posted December 29, 2006 you cant compare the submittedusername with $username like that since username is an array... Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149126 Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 Also note that variables do not need to be surrounded by quotes, and in particular variables contained within single quotes will not be parsed. Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149131 Share on other sites More sharing options...
corbin Posted December 29, 2006 Share Posted December 29, 2006 Yeah hehe I didnt even notice that... In the case of variables compared to variables you should never use quotes... Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149134 Share on other sites More sharing options...
HoTDaWg Posted December 29, 2006 Author Share Posted December 29, 2006 just out of curiousity, if i make password an array as well would it function? Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149137 Share on other sites More sharing options...
trq Posted December 29, 2006 Share Posted December 29, 2006 [quote]just out of curiousity, if i make password an array as well would it function?[/quote]No. Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149139 Share on other sites More sharing options...
HoTDaWg Posted December 29, 2006 Author Share Posted December 29, 2006 thanks a lot guys. but i changed the login.php script to:[code]<?php$submittedusername= $_REQUEST['submittedusername'];$submittedpassword= $_REQUEST['submittedpassword'];$username= "xxxxx"$password="xxxxxxxx";if ($submittedusername==$username && $submittedpassword==$password){header("Location:http://www.yahoo.com/");} else {echo "Access Denied";}?>[/code]but i still get this error:[code]Parse error: syntax error, unexpected T_VARIABLE in /home/mediacir/public_html/djscript/login.php on line 6[/code] Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149140 Share on other sites More sharing options...
HoTDaWg Posted December 29, 2006 Author Share Posted December 29, 2006 wait never mind, i see one mistake. ALright guys topic solved thanks! gimme a couple of minutes and ill mark it solved as well. Link to comment https://forums.phpfreaks.com/topic/32134-solved-login-script-error/#findComment-149142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.