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
avatar
Mac
Re: Topic 5B
May 03, 2006 06:14PM
libbyy - since when two y's?

Dear oh dear.... winking smiley Your fellow students are not forthcoming.

You send it with a GET, then request it with a $_POST????

How did I know????

I added a echo "mmmm $color"; to setcookie.php The mmm just to make sure it is indeed echoed. Nothing forthcoming, so I knew the error was on the 1st page. Error checking. Posted this before. Learn to use it (although there are no gauarantees smile.

phantom.....

Taste. Some editors generate forms for you, but with double quotes, which, if you echo it, you either have to escape with an \ or convert to '.

Methinks why you want to do all that? You get no brownies for typing a form - let the editor do it, and use php where required. The difference in speed is minimal.

Re: Topic 5B
May 03, 2006 06:51PM
I forgot my password so had to re-register, hence the double y - the forgotten password thing doesn't seem to be working.

thanks for the advice Mac - yep, that was a wee bit thick of me ... but let's blame it on the headcold from hell ...
Re: Topic 5B
May 03, 2006 08:57PM
Now the form is working and the cookie is appearing in the cookies folder but when I go back and refresh I don't get the 'Delete Cookie' link.
I thought it might be the cookie settings on my browser but that doesn't help and I've tried it in firefox and opera and the same result.

My cookie lookslike this:
background
%234682B4
localhost/studentphp/
1024
3531959552
29781738
1893727920
29781730
*

Any suggestions?
Re: Topic 5B
May 03, 2006 09:00PM
ignore my last message. I uploaded the cookie files onto an external server and works just fine so must be one of my local settings.
Re: Topic 5B
May 04, 2006 07:52AM
Thanks Wayne Rothman.
The spelling was wrong indeed but that did not fix my problem.

I put $background = $_COOKIE[background]; before if($background) and it worked.

I think my PHP server is by default set to a high security level in my php.conf (working on a linux plaform).

Try it Libbyy. I think you are having the same problem.

Murphy's Technology Law 7
-- The attention span of a computer
is only as long as its electrical cord.
Re: Topic 5B
May 04, 2006 08:17AM
OK I am lost

where will the color be displayed?
mine is displayed in teh address bar but the color of the screen does not change.

then I seem to have an added issue in that I do not have a Cookies folder inside the windows folder, I am working with XP. Could this be due to network security software and policy implementations?

HELP
Re: Topic 5B
May 04, 2006 08:28AM


The cookies folder in XP is hidden away under documents and settings and then the user name.
Re: Topic 5B
May 04, 2006 01:59PM
thanks mac,

thats what i also think. Plus if the html code is not in an echo it is easier to see errors, (but then again this depnds on the editor in use)

Re: Topic 5B
May 11, 2006 10:28AM
OK I am still lost after spending too many hours on this

please help

Cookie
<?php
$background = $_COOKIE[background];

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

$color=$_POST['color'];

"mmmm $color";

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

}

//INSERT CODE HERE TO SET THE COOKIE
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 11, 2006 03:10PM
I have completed this topic
Sorry, you do not have permission to post/reply in this forum.