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