Distant_storm Posted January 16, 2008 Share Posted January 16, 2008 I have a script that sends form data to another the simplest php script ever yet when it goes to the login page it says 404 error page not found. Refresh the page and its although the data hasn't been sent but displays the error page. Why is this happening, here is the scripts... <form method=POST action=login.php><table><tr><td colspan=2><center><b>Login</b></center></td></tr> <tr><td>Username: </td><td><input type=text name=us></td></tr> <tr><td>Password: </td><td><input type=password name=pa></td></tr> <tr><td colspan=2><center><img src=cap.php></center></td></tr> <tr><td colspan=2><center><font size=2pt>Type the word in the text box below</font></center></td></tr> <tr><td colspan=2><center><input type=text name=inv></center></td></tr> <tr><td colspan=2><center><input type=submit name=log value=Login></center></td></tr> </table></form> login.php <?php //simple password $press_pw="23d45b337ff85d0a326a79082f7c6f50"; $count_pw="5f6371c9126149517d9ba475def53139"; if (ctype_alnum($_POST['us']) AND ctype_alnum($_POST['pa'])) { $in_pw=md5($_POST['pa']); $in_us=$_POST['us']; switch ($in_us) { DEFAULT: header("Location:error.php"); break; case "scfc": if ($count_pw != $in_pw) { header("Location:error.php"); } break; case "press": if ($press_pw != $in_pw) { header("Location:error.php"); } break; } $ip=$_SERVER['REMOTE_ADDR']; setcookie ("key",$in_pw,time() + 3600*24,'/','',0); setcookie ('user_id',$ip,time() + 3600*24,'/','',0); $tag=$_POST['inv']; header("location:anuthpage.php?inv=$tag"); } else { header("Location:error.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/ Share on other sites More sharing options...
tapos Posted January 16, 2008 Share Posted January 16, 2008 Please make sure that every php file in the same directory. -- Thanks Tapos Pal http://tapos.wordpress.com Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-441078 Share on other sites More sharing options...
Distant_storm Posted January 16, 2008 Author Share Posted January 16, 2008 both files are in the same directory Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-441080 Share on other sites More sharing options...
revraz Posted January 16, 2008 Share Posted January 16, 2008 Try putting quotes around the filename after action= Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-441093 Share on other sites More sharing options...
kenrbnsn Posted January 16, 2008 Share Posted January 16, 2008 Do some debugging... Change the header() functions to exit(). This way you will know the path through the code that is being taken. Also, I've always put the "default" case at the end of the switch statement. One more thing -- using proper indentation of your code is always helpful. Something like: <?php /simple password $press_pw="23d45b337ff85d0a326a79082f7c6f50"; $count_pw="5f6371c9126149517d9ba475def53139"; if (ctype_alnum($_POST['us']) AND ctype_alnum($_POST['pa'])) { $in_pw=md5($_POST['pa']); $in_us=$_POST['us']; switch ($in_us) { case "scfc": if ($count_pw != $in_pw) exit('[case scfc --> Location:error.php]'); break; case "press": if ($press_pw != $in_pw) exit('[case press --> Location:error.php]'); break; default: exit("[default --> Location:error.php]"); } $ip=$_SERVER['REMOTE_ADDR']; setcookie ("key",$in_pw,time() + 3600*24,'/','',0); setcookie ('user_id',$ip,time() + 3600*24,'/','',0); $tag=$_POST['inv']; exit("[location:anuthpage.php?inv=$tag]"); } else exit("[Location:error.php]"); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-441153 Share on other sites More sharing options...
Distant_storm Posted January 17, 2008 Author Share Posted January 17, 2008 Still getting error ive addapted the code but not to ken's standard because ive never had to do it any other way in the past and its been fine. im thinking its something else. here is my adapted login part of the code. I still get 404 error which is really anoying because its such simple code.. <?php ob_start(); //simple password $press_pw="23d45b337ff85d0a326a79082f7c6f50"; $count_pw="5f6371c9126149517d9ba475def53139"; $error="FALSE"; if (empty($_POST['inv'])) { $tag="n"; } else { $tag=$_POST['inv'];aa } if (ctype_alnum($_POST['us']) AND ctype_alnum($_POST['pa'])) { $in_pw=md5($_POST['pa']); $in_us=$_POST['us']; switch ($in_us) { case "scfc": if ($count_pw != $in_pw) { $error="TRUE"; } break; case "press": if ($press_pw != $in_pw) { $error="TRUE"; } break; DEFAULT: $error="TRUE"; break; } $ip=$_SERVER['REMOTE_ADDR']; setcookie ("key",$in_pw,time() + 3600*24,'/','',0); setcookie ('user_id',$ip,time() + 3600*24,'/','',0); header("location:XXXXXXX?inv=$tag"); } else { $error="TRUE"; } if ($error=="TRUE") { header("Location:error.php"); } ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-442269 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.