Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 22nd, 2002, 10:19 PM
sirrusdi sirrusdi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 8 sirrusdi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to sirrusdi
Angry Header Problem!!!

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!

Reply With Quote
  #2  
Old November 22nd, 2002, 10:38 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 7
Here is your problem ->
PHP Code:
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'); 

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.




Reply With Quote
  #3  
Old November 22nd, 2002, 10:51 PM
sirrusdi sirrusdi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 8 sirrusdi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to sirrusdi
Ok. Thanks.

The URL is wrong.

http://www.sirrusdigital.com/$username/index.php

why?

Reply With Quote
  #4  
Old November 23rd, 2002, 12:04 AM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 7
change this ->

PHP Code:
/*
Change this ->
*/
header('Location: /$username/index.php');
/*
To this ->
*/
header('Location: /' $username '/index.php'); 

Reply With Quote
  #5  
Old November 23rd, 2002, 11:28 PM
sirrusdi sirrusdi is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 8 sirrusdi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to sirrusdi
The result was a unexpected T_STRING.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Header Problem!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT