Page 1 of 1

Login and Re-Direct

Posted: Sun Apr 01, 2007 12:32 pm
by cupaball
Okay I would like to have a MySql database the holds client into like, username, pw, company, and url direct. (Which I have already done)

I would like to have client login which when the client enters there correct information, it takes them to their page. I have the login down, I just can't figure out how to make it redirect. By the way, I used Dreamweaver to create the login. (don't hold that against me)

Let me know your thoughts.

Posted: Sun Apr 01, 2007 12:53 pm
by John Cartwright

Code: Select all

$result = mysql_query(' .... ') or die(mysql_error()); // fetch user info, aswell as check against username and password

if (mysql_num_rows($result) > 0) //user was found
{
   $row = mysql_fetch_assoc($result);

   header('Location: http://domain.com/profile.php?id='. $row['id']);
   exit();
}
As you can see, header() is used to redirect the user. However, you must make sure there has been no output sent if you are sending a header, or you'll run into the dreaded Output already sent error.

Posted: Sun Apr 01, 2007 1:29 pm
by feyd
you can use headers_sent() to judge how you should output the redirection, potentially.

Posted: Sun Apr 01, 2007 6:52 pm
by cupaball
thanks, I will give this a try tomorrow.