Jump to content

I Cant Figure Out The Cookie Thing


jarrett000

Recommended Posts

Ok, i have a site where you put your name in a text box on the first page then redirects you to the homepage on submit(This one). On the homepage it'll say "Welcome <?php $_GET['name'] ?>" and that usually works. However, when the user loads the page without inputing their name the page will reload and anywhere the was <?php $_GET['name'] ?> is now blank(As you can see here). Can anyone help?

Link to comment
Share on other sites

It sounds like you want your script to remember the users name. You are correct the cookies is the way to go about that. Investigate the setcookie() function and the $_COOKIE array. Any cookies you have set on a client browser are automatically sent back to your server every time a client loads your document, so you just have to look in $_COOKIE to find them.

Link to comment
Share on other sites

I've tried that already, mohammad molana, but problem is that i got an error message that says:Warning: Cannot modify header information - headers already sent by (output started at /home/reaperw1/public_html/Jarrettcode.com/Home.php:3) in /home/reaperw1/public_html/Jarrettcode.com/Home.php on line 10

Link to comment
Share on other sites

That happens when you've already output ANYTHING. There can be zero echo statements or html sections before the header() call. An html section is anything before or between <?php ?> tags, including line breaks and blank spaces, even if there are no visible characters. Anyone who writes PHP has been burned like that at least once.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...