Unfortunately, some of you didn't take last week's work seriously. I had hoped that you were motivated enough to tackle the exercises even though they did not have to be submitted. I guess in some cases I was mistaken. Mea culpa.
Accordingly, I require you to submit guy.php
from lab 11.
If you did not finish it, then do so in your own time.
Submit guy.php
(not a zip file) in the usual way, selecting
LAB11 when prompted. Deadline: 1 pm, Tuesday 5th February.
Inside your public_html/cs1102
folder, create a subdirectory
called lab12
(all lowercase) to hold this week's work.
Let's start with something very simple.
dec.html
based on template.html
.
(NB: .html
, not .php
). Viewed in a browser, this file
should display a form comprising just one label, one text-field
and a submit button.
The user will type a decimal number into the text-field. When s/he presses the submit
button, his/her data will be sent to the server (using the GET method), where it
will be processed by a PHP script called dec2bin.php
.
dec2bin.php
based on template.php
.
(NB: .php
, not .html
).
$_GET
that makes this available to you.)
decbin
. Suppose n
is an integer in decimal.
Then decbin(n)
converts n
to binary and returns
the result. E.g. decbin(8)
returns 1000.
echo
to write both the user's decimal number and the corresponding
binary number to the output.
A more professional version of this program would check the user's input. If s/he fails to type a decimal number, e.g. s/he types "hello Mum", the script would display an error message. You need not bother with this, unless you particularly want to.
Create an XHTML web page in a file rsp.html
and a PHP script
in a file called rsp.php
.
The web page displays a form containing three radio buttons, labelled
Rock, Scissors and Paper. It submits the
user's data using the GET method to the PHP script, rsp.php
The PHP script
if
statements to compare what the system has generated with
what the user has selected, where
Zip your lab12
folder and submit lab12.zip
in the usual
way, selecting LAB12 when asked.
Deadline: 1pm, Tuesday 5th February.