HTML and CSS Reference
The Server-Side PHP Script
echo "<span style='color:red'>Please enter your name.
echo "<span style='color:red'>Please enter your phone number.
echo "Welcome <b>$username</b>. Your phone number is
This PHP function extracts the data from a global associative array called
$_REQUEST . It contains any name/value pairs submitted from the HTML form
and sent with either GET or POST requests; in this example, the array contains
two sets of name/value pairs:
username => “Ebenezer Scrooge”
userphone => “0207 626 4388”
PHP's extract function creates a variable, $username , for the name and assigns it
the value “Ebenezer Scrooge” and another variable called $userphone with a value
of “0207 626 4388”. (This information was sent in the server request in a param-
eter: ?username="namevalue+"&userphone="+phonevalue . Figure 18.16 shows a
If the variable is empty (i.e., null), tell the user.
If the user didn't enter anything in the textfield, he or she will be sent this message
in red letters defined by the <span> tag (see Figure 18.17).
The PHP program exits here.
If the user doesn't type anything in the phone field, he will get a message in red
telling him or her to enter his or her phone number (see Figure 18.18).
The PHP program echo's a string of text to the server. The server will respond by
sending the text to the Ajax program where it will be received (line 3 in the Ajax
program) and displayed (line 4 in the Ajax program).