Welcome! Log In Create A New Profile

Advanced

Topic 5B

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Anonymous User
Topic 5B
January 16, 2006 08:20AM
This is the thread for problems/comments related to Topic 5B.
Re: Topic 5B
April 18, 2006 10:12PM
My code working. Just one error. After the cookie is set and I refresh the page with Cntl-F5, the link description is not display to delete the cookie, but the link itself is on the page.

echo "<a href='delete_cookie.php'>Wanted to delete cookie?</a>";

The words "Wanted to delete cookie" is not display until I click on the link to delete the cookie.
Re: Topic 5B
April 25, 2006 10:12PM
Topic complete.

Miekie, check that you have not set the vlink='$background'
Re: Topic 5B
April 25, 2006 10:34PM
"Slim seun". Thanks Wayne, I have the vlink='white' and the default background was also white. smiling bouncing smiley All done and working fine now.
Re: Topic 5B
April 27, 2006 02:54PM
All done. Took me a while to figure the $_COOKIE[] thing, but i got it smiling smiley I must be getting a bit slow in my old age.
Re: Topic 5B
April 30, 2006 08:20PM
Ok. my cookie is being created but it seems it not being loaded when the page is reseted (color goes back to white and delete link does not appear)

In coockie.php I have added:
If ($background)
{
echo "<html>";
echo "<head><title>Selected Background Color</title></head>";
echo "<body bgcolor='$bachground' vlink='$background'>";
echo "<a href='delete_cookie.php'>Delete Cookie</a>";
echo "</body>";
echo "</html>";
}


in set coockie I have added:
setcookie("background",$bgcolor,time()+3600);

echo "<html>";
echo "<head><title>Selected Background Color</title></head>";
echo "<body bgcolor='$bgcolor'>";
echo "</body>";
echo "</html>";


$background stays null after refreshing.

What am I missing? sad smiley

Murphy's Technology Law 7
-- The attention span of a computer
is only as long as its electrical cord.
Re: Topic 5B
April 30, 2006 11:33PM
Taki,

Check the spelling of your variable $background in cookie.php, and set your vlink to 'white'
Re: Topic 5B
May 02, 2006 11:10AM
Wonders what you can do in a long weekend. Topic completed.
Re: Topic 5B
May 02, 2006 04:07PM
I'm battling with this one - no error messages but it doesn't work. Any ideas?


COOKIE.php
<?php

if ($background)
{
echo "<html>";
echo "<head><title>Selected Background Color</title></head>";
echo "<body bgcolor='$background' vlink='white'>";
echo "<a href='delete_cookie.php'>Delete cookie</a>";
echo"</body>";
echo "</html>";
}




else
{
echo "<html>";
echo "<head><title>Select a Background Color</title></head>";
echo "<body>";
echo "<form method=GET action='setcookie.php'>";
echo "Select a background color";
echo "<br>";
echo "<input name='color' TYPE='radio' VALUE='Yellow'> Yellow";
echo "<br>";
echo "<input name='color' TYPE='radio' VALUE='Blue'> Blue";
echo "<br>";
echo "<input name='color' TYPE='radio' VALUE='Silver'> Silver";
echo "<br>";
echo "<input name='color' TYPE='radio' VALUE='Beige'> Beige";
echo "<br>";
echo "<br>";
echo "<input type='submit'>";
echo "</form>";
echo "</body>";
echo "</html>";
}
?>

SETCOOKIE.php
<?php

$color=$_POST['color'];

switch ($color) {
case "Yellow":
$bgcolor="#FFCC00";
break;
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;

}

setcookie ("background", $bgcolor, time()+3600);



echo "<html>";
echo "<head><title>Selected Background Color</title></head>";
echo "<body bgcolor='$bgcolor'>";
echo "</body>";
echo "</html>";
?>
Re: Topic 5B
May 03, 2006 12:19AM
completed topic.

just a question, I think it appeared somewhere before.

What is better? since i am checking out libbyy code

running html inside the php like libby did or running html code and addning in <!php tags where php is needed?

Sorry, you do not have permission to post/reply in this forum.