|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I get a header problem when I redirect. The error is
Warning: Cannot add header information - headers already sent by (output started at /home/sirrusdi/public_html/new_site/log-in.php:29) in /home/sirrusdi/public_html/new_site/log-in.php on line 32 Any hints? Also I want it to redirect to the persons /username/index.php but that doesn't work. Not Found The requested URL /Resource id was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. It sould go to /sirrusdi/index.php. HERE IS THE ENTIRE CODE: <?PHP mysql_connect($host, $user, $pass); mysql_select_db("sirrusdi_db1") or die(mysql_error()); $_POST['user'] = addslashes($_POST['user']); $_POST['pass'] = md5($_POST['pass']); $result = mysql_query("SELECT count(userId) FROM users WHERE userPass='$_POST[pass]' AND userName='$_POST[user]'") or die("Couldn't query the user-database."); $num = mysql_result($result, 0); $username = mysql_query("SELECT userName FROM users WHERE userName='$_POST[user]'"); // Start the login session session_start(); $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; echo "<h1>Congratulations</h1>"; echo "You're now logged in. <a href='/$username/index.php'>Click Here to veiw web page.</a>."; header('Location: /$username/index.php'); ?> Thank You! |
|
#2
|
|||
|
|||
|
Here is your problem ->
PHP Code:
Now, let me explain. Before the server can send anything to the user, it must send a header to the clients browser. Your code is telling the clients browser to accept some data (where you have the echo statements at). Now, before the clients browser will accept the data, it has to recieve the headers. So, you are sending the headers, then outputting data, then trying to send more headers - which in a nutshell will not work. If you want to redirect to another page after you send data, echo a meta-refresh tag within the HTML document head.....
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
|
#3
|
|||
|
|||
|
|
|
#4
|
|||
|
|||
|
change this ->
PHP Code:
|
|
#5
|
|||
|
|||
|
The result was a unexpected T_STRING.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Header Problem!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|