Hi,

I have a login page that has a form that goes to processing page wich the has the logic that in case login fields are empty or invalid to redirect back to login page with result variable set to "badlogin". I ran it a couple times and it worked fine. Then all of a sudden: when I run it, the original login page doesn't reload after being redirected from processing. I have to hit refresh on a browser for it to come up.

Here is the code freom my processing page that redirects it: 
$user = $_REQUEST["username"]; 
$pass = $_REQUEST["password"]; 
$logintype = $_REQUEST["logintype"]; 
if( "" == $pass || !preg_match( "^[a-zA-Z]+^", $pass ) ){ 
$error = 1; 
} 
if( 0 != $error ){ 

if ( $logintype == "admin" ) { 
header( "Location: ../LoginAdmin.php?loginresult=badlogin" ); 
include( "../LoginAdmin.php" ); 
exit(); 
} 

exit(); 
}

If it was working than maybe it could be you cache?

replace the header script with javascript may solve the problem.

//you php code here...
  ?>
  <script language="JavaScript" type="text/javascript">
  <!--
  window.location.href = "../your_page.php"
  //-->
  </script>
  <?php 
  exit;
  //  other php code

The include( "../LoginAdmin.php" ); will have to include in the forwarding page.

First of all, I might be drunk, but the header() functions redirects right away to the given location, so theres no need to call exit() and the include() below wont have any effect; you might wanna take that in account first

Hey people .... i need your help!
I am having the same problem ....

I have tried cleaning up my cache memory.... apparently it doesn't help, because the second time I open the browser it responds in the same manner, by showing me the blank browser... which i need to refresh manually .

The wierd thing is that Mozilla Firefox is absolutely fine ... the same redirects work just fine. I have tried infinitely many times.... no problem, perfect.

But IE 6, for some reason, has problems with it....

I am using Header("Location: xxx.php"); to redirect to other page...

i have tried everything possible... even when i put header function as the first function in my code it shows me the damned blank page....

Before, I thought that the problem might be in sending HTTP headers... but i why then mozilla works just fine???


PLEEEEEEEEEEEEEEEZ
if anyone has a solution for the problemmm..... let me know
I appreciate your help....

Gah! Your PHP Code is an absolute disaster, sorry to say, and it hurts my eyes. This might help:

<?php
// Here is the code from my processing page that redirects it: 
$user = $_REQUEST['username']; 
$pass = $_REQUEST['password']; 
$logintype = $_REQUEST['logintype'];
// Gah! ALWAYS, when using preset variables, use
// single quotes inside brackets. PHP is more friendly,
// that way :P Also, are you trying to get this data
// from a form? You might want to change these to POST,
// and set the form in your HTML page to be POST, as well,
// but for now I'll just leave them as they are.

if($pass == '') { 
   // There is no point using preg if you're going to search for
   // a-z and A-Z, it's easier to just use if($pass == '').
   $error = 1; 
};
if($error == 0) { 
   if ($logintype == 'admin') { 
      header('Location: ../LoginAdmin.php?loginresult=badlogin'); 

      // include("../LoginAdmin.php" );
      // Why are you including a page here? You've already
      // been redirected to the other page!

      exit; 
      // The 'exit;' command does not have parameters, therefore
      // do not put parenthesis () after it.
   };
exit; 
};
?>

If you are not being redirected to that page, you are doing something wrong, and by the looks of your PHP code, you are. :confused:

Also, if this is a user authentication form, I'd suggest using a database with usernames and passwords, simply testing if the user has entered a password is not secure at all, especially if you then redirect them to an Administration page. Troy has some good tutorials on the subject, you might want to get in touch with him. ;)

Also, zippee, it is pointless to end your PHP script just so that Javascript can redirect you to a page, especially if PHP can do it for you. The correct way to redirect someone to a page:

<?php
header('Location: http://www.google.com/');
?>

will redirect you to Google. This header(); function MUST be executed before any other headers are, otherwise you will get an error.

It seems like I got the way around this problem.... :)

If you have any useless stuff in headers, like for example....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

get rid of it... for some reason it worked for me.

Why people use all those w3c advised headers anyways???

:cool:
hope I was helpful

If you have any useless stuff in headers, like for example....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> get rid of it... for some reason it worked for me.

Ahh, yes, that's right, many HTML editing programs, such as Macromedia Dreamweaver add that to every page, so removing it (since it is a header) will allow the Location Header to be sent, even with a relative link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.