Jump to content

Redirect issues


djw821

Recommended Posts

I am trying to redirect from my login script to my members page.  I can't seem to do it. I use this code

 

if($row) {

header('Location: Members.htm');

exit();

 

 

}else{

print '<p><font color = "red" size = "+1">The Username and Password do not match those on file.</font></p>';

 

If I subsitute the header function for a print function

ex if($row{

print '<p>SUCCESS</p>';

 

It will work so I am pretty sure that $row is correct.

 

But if I use the header function I get a blank white screen no error messages or anything.

 

Can some one help me?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/95096-redirect-issues/
Share on other sites

Here is the section of code.

 

$query = "SELECT user_id, first_name FROM registration WHERE user_name ='$un' AND password=PASSWORD('$p')";

$result = @mysql_query ($query);

$row = mysql_fetch_array ($result, MYSQL_NUM);

 

if($row) {

header('Location: Members.htm');

exit();

 

}else{

print '<p><font color = "red" size = "+1">The Username and Password do not match those on file.</font></p>';

 

}

ob_end_clean();

mysql_close();

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/95096-redirect-issues/#findComment-487158
Share on other sites

What I was doing worng was this:

1

2<?php ob_start;  when I change it to

 

1<?php ob_start; it worked I just needed to mover the ob_start to the very top of the page even though there was nothing there.

 

that's nothing there is a thing in php, that's a linebreak and this is output so the header wont work :)

 

in case of header or cookies, no output must be sent before the header or cookies, wether its an echo, a line break or what ever...

 

in your case, starting at the secod line is equals to echo "\n"; so the page has output :)

Link to comment
https://forums.phpfreaks.com/topic/95096-redirect-issues/#findComment-487659
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.