How to send cookie to the next page??
Posted: Wed Jul 09, 2008 1:02 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
hey guys...i have problems with setcookie and sending it to the next page..it returns "cannot modify header, header already send in (C://....) in line... "
below are my codes....could u guys see if i did anything wrong
------------------------------------------------------------------------------------
and it return this
-------------------------------------------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 23
katil
--------------------------------------------------------------------------------------
where "katil" is my $list['title'] value
my next page is picture.php....but when i click the word "katil" which wanted to go to the next page...there is no image which seems no cookie had been send from previous page.
by the way..what should i replace this "/~rasmus/", ??
thanks,
Azhan
________________________
http://www.productcoverdesign.com- "Cheapest E-Cover Design"
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
hey guys...i have problems with setcookie and sending it to the next page..it returns "cannot modify header, header already send in (C://....) in line... "
below are my codes....could u guys see if i did anything wrong
------------------------------------------------------------------------------------
Code: Select all
<?php
// Connects to your Database
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("hospital") or die(mysql_error());
$id = $_COOKIE['ID_my_site'];
$take = mysql_query("SELECT name FROM patientlist WHERE id = '$id'");
while ($taking = mysql_fetch_array($take)) {
echo "Retrieving Images From Patient Named: <fontcolor='red'>".$taking["name"]."</font><br>\n";
print "Below are the title of the currently stored images, click on the title to view" ;
}
$id = $_COOKIE['ID_my_site'];
$result = @mysql_query("SELECT * FROM pix WHERE pid ='$id'");
while ($list = mysql_fetch_array($result))
{
if (!$result) {
die( ' no data');}
else {
$value = '"'.$list['title'].'"';
setcookie("TestCookie", $value); //line21
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */ //line22
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".picture.php", 1); //line23
echo "<br><a href='picture.php'>".$list['title']."</a>"; }}
?>and it return this
-------------------------------------------------------------------------------------
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 21
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\get2.php:9) in C:\xampp\htdocs\get2.php on line 23
katil
--------------------------------------------------------------------------------------
where "katil" is my $list['title'] value
my next page is picture.php....but when i click the word "katil" which wanted to go to the next page...there is no image which seems no cookie had been send from previous page.
by the way..what should i replace this "/~rasmus/", ??
thanks,
Azhan
________________________
http://www.productcoverdesign.com- "Cheapest E-Cover Design"
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: