In Notepad, create a new HTML file called phplab4.html. Insert the following HTML code, which creates a form.
<HTML> <HEAD> <TITLE>PHP lab 4 </TITLE> </HEAD> <BODY> <FORM ACTION="phplab4_result.php" METHOD="POST"> Enter a number: <BR> <INPUT TYPE="TEXT" NAME="yournumber"><BR> <INPUT TYPE="SUBMIT" VALUE="Go"><BR> </FORM>
View phplab4.html in your web browser. You should see a spot for entering in a number, and a "Go" button.
Experiment with the above HTML by selectively removing lines and seeing what happens. Answer the following questions:
Now create in Notepad a new file called "phplab4_result.php", and enter into it the following:
<HTML> <HEAD> <TITLE>PHP lab 4 results </TITLE> </HEAD> <BODY> <?php print("Here is your number: $yournumber <BR>"); $square = $yournumber*$yournumber; print("Here is your number squared: $square <BR>"); ?> </BODY> </HTML>
Now try your phplab4.html web page again, type in a number, then click the "Go" button. If all goes correctly, you should see a new web page that does some calculations based on your numbers.
Here is a final exercise: