Welcome! Log In Create A New Profile

Advanced

Topic 2A

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 2A
January 16, 2006 08:22AM
This is the thread for problems/comments related to Topic 2A.
Re: Topic 2A
February 15, 2006 09:59AM
I am bussy with the activity 2-1 on page 18 of masterskill

I cannot get it working
apache and MySQL are running

I have saved both the files in the same folder
ie c/FoxServe/www/StudentPHP

how do I get the designer to help me debug my code? at the moment I am not getting any error messages. I have commented most the code out so as to reduce the possible sources of problems

<?php
switch ($color)
{
case "Yellow":
$bgcolor="#FFCC00";
break;
/*
case "Blue":
$bgcolor="#4682B4";
break;
case "Silver":
$bgcolor="#C0C0C0";
break;
case "Beige":
$bgcolor="#FFE4C4";
break;
*/
}

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

?>
avatar
Mac
Re: Topic 2A
February 15, 2006 12:01PM
Let me get this right - are you saying there are errors but Designer is not showing you where they are, since the code here above will and should not give an error - it is correct.

The designer will only debug if there are errors, i.e. to show you where the errors in your code are.
Re: Topic 2A
February 15, 2006 12:36PM
I agree that the above code is as it is in the manual BUT it does not run correctly when I open colorselect.html using localhost

I see the radio buttons and so on but when I make a selection and when I submit the query I do not get the desired result

as I mentioned earlier both these files are in the studentPHP folder
Re: Topic 2A
February 18, 2006 12:26PM
Hello..

I'm also having a problem displaying the script results using http://localhost

If I upload the html page and color.php script to a server, it works fine - all colours display as they should.

I wonder if we haven't installed everything on our pc's correctly - php files show, but when executing them, they don't display anything.
avatar
Mac
Re: Topic 2A
February 20, 2006 08:19AM
Let's do this another (and the more correct way).

In colorselect.php change to GET to POST.

<form method=POST action='color.php'>

Using GET, if you watch the URL when you get to color.php, you will notice the following appended to the http://localhost/color.php

?color=blue (or whatever color you selected)

So the GET method allows us to see what was sent to the page - which is very helpful for error checking or finding out what has gone wrong if things are not working.

POST hides this info - better to use since we sometimes don't want to broadcast what we are sending. So use GET to make sure everything was sent correctly, It was, so we know the fault does not lay with colorselect.php, but with color.php, since the color is seemingly not picked up.

If you, for example, add echo "$color"; to the top of the page, it should print "blue" or whatever, since PHP turns color=blue (which was sent to the page in the URL) automatically into the variable $color, and assigns is the value blue.

BUT, bacause of the security reasons mentioned, changes are taking place as PHP is upgraded.

Add $color=$_POST['color']; to the top of color.php. This tells the server to extract 'color' from 'POST' and assign it to $color.

So, always use $whatever=$_POST['the_formarea_input']; when using forms.












Re: Topic 2A
February 21, 2006 08:20AM
This topic is completed, no problems.
Re: Topic 2A
February 21, 2006 03:55PM
OK I am with on this one now
Re: Topic 2A
February 24, 2006 01:35PM
Topic completed without any problems.
Re: Topic 2A
February 24, 2006 03:10PM
Ok..

Changed the settings in color.php and the HTML page, and all works now in my browser.

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