Jump to content

Recommended Posts

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");

}

Link to comment
https://forums.phpfreaks.com/topic/86325-404-error-why/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-441153
Share on other sites

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();
?>

Link to comment
https://forums.phpfreaks.com/topic/86325-404-error-why/#findComment-442269
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.