pcw Posted May 18, 2009 Share Posted May 18, 2009 Hi, I have got this script that confirms that a correct password was entered <?php case "logchk": include_once("data/adminpw.php"); $useradmin = $_POST['useradmin']; $adminpass = base64_encode($_POST['adminpass1']); for($i=0; $i < count($data); $i++) { if(($useradmin == $data[$i]['useradmin']) && ($adminpass == $data[$i]['adminpass1'])) { $authorised = 'true'; } } if(!isset($authorised)) { exit("You have entered the incorrect password. Please try again."); } setcookie('sbadmin', $useradmin, time()+3600); header( 'Location: admin.php?cmd=panel' ); echo "login successful"; break; ?> This confirms the login was successful but does not redirect the user to admin.php?cmd=panel This did work, the only change I have made is to upgrade to IE8 - could this be what the problem is. Or have I made a mistake somewhere? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/ Share on other sites More sharing options...
thebadbad Posted May 18, 2009 Share Posted May 18, 2009 Are you sure that you're not outputting anything before the header() call? I see the code you posted is only a part of a script. Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836463 Share on other sites More sharing options...
pcw Posted May 18, 2009 Author Share Posted May 18, 2009 Hi, yes, there is other coding between other case "": and break; tags on the page I think I may need to place an ob_start(); somewhere in case "logchk": but cant work out where. Have I got the right idea? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836471 Share on other sites More sharing options...
thebadbad Posted May 18, 2009 Share Posted May 18, 2009 No, if the problem is output before the header() call, the real solution would be to remove such output, as it doesn't make sense to output anything if the user is immediately redirected. Is there any output before the header() call? Could also be in any included file. Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836481 Share on other sites More sharing options...
BobcatM Posted May 18, 2009 Share Posted May 18, 2009 Make sure there are no lines above <?php - what was wrong with mine one time. Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836483 Share on other sites More sharing options...
pcw Posted May 18, 2009 Author Share Posted May 18, 2009 The only output before the header() call is setcookie('sbadmin', $useradmin, time()+3600); but even if I remove this, I still have the same problem. The output for a successful login is under case "panel": which is in the code below this part of the script. Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836486 Share on other sites More sharing options...
pcw Posted May 18, 2009 Author Share Posted May 18, 2009 Just to let u know, I dont get any errors, it just doesnt redirect Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836488 Share on other sites More sharing options...
premiso Posted May 18, 2009 Share Posted May 18, 2009 Post the entire code please. As it is obvious we need more information. As for the "not getting any errors" do you have the following after the first <?php in your script to make sure errors are turned on? error_reporting(E_ALL); ini_set("display_errors", "on"); Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836491 Share on other sites More sharing options...
pcw Posted May 18, 2009 Author Share Posted May 18, 2009 Hi premiso, thanks for your reply. It would be impossible to post all the code, as the script is huge. I added the error reporting and solved the problem of the header function. However, I now get this error Notice: Undefined index: case in /home/moveitho/public_html/cgi-bin/sitebuilder/admin.php on line 5 which is this line: $cmd = $_GET['cmd']; this was all working fine before I upgraded to IE8, whats going wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836504 Share on other sites More sharing options...
premiso Posted May 18, 2009 Share Posted May 18, 2009 $cmd = isset($_GET['cmd'])?$_GET['cmd']:''; Will fix the undefined index. It was not all "working fine" you just did not have errors reporting out. As far as why it took effect with IE 8, no clue. Could have been a buffering issue with IE 7 or 6 that IE 8 fixed. Quote Link to comment https://forums.phpfreaks.com/topic/158599-redirect-not-working-in-previously-working-script/#findComment-836511 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.