1) Create a form that asks a user for his/her name and some comments. Then create two PHP scripts that create a response. The first script displays the information which the user has submitted ("Hello $name. These are your comments: $comments") and asks the user whether he/she really wants to submit the information. The second script is invoked by the first one and displays "Thank you $name. Your comments have been submitted: $comments". Form:
Name:

Comments:

----------------------------------------------------------------- First PHP Script: Maintaining State Invalid Input"; exit; } echo "
Hello $name! Do you really want to submit these comments?

$comments

"; ?> ----------------------------------------------------------------- 2) Use a cookie instead of hidden text in the previous exercise First PHP file: Maintaining State"; echo "Invalid Input"; exit; } $cookiedata = $name."|".$comments; setcookie("nameandcomments", $cookiedata, time()+3600); echo " Maintaining State
Hello $name! Do you really want to submit these comments?

$comments

"; ?> ----------------------------------------------------------------- Second PHP file: Maintaining State

Reply

Invalid Input"; exit; } echo "

Hello $name. Here are your comments:

$comments"; ?> ----------------------------------------------------------------- 3) Use PHP session handling functions for the previous exercise First PHP file: Maintaining State"; echo "Invalid Input"; exit; } $_SESSION['name'] = $name; $_SESSION['comments'] = $comments; echo " Maintaining State Hello $name! These are your comments:

$comments

"; ?> Click here to submit them. ----------------------------------------------------------------- Second PHP file: Maintaining State

Reply

Hello $name. Here are your comments:

$comments"; ?> ----------------------------------------------------------------- 4) Hit counter: create a file that contains only the number "0". Your PHP script must open that file for reading; read the first line of the file into a scalar variable; increase the number by one; close the file; open the file again for writing (not appending); write the number to the file; close the file. Because of permissions, first, you need to create and save the file manually. Then you need to change the file permissions to 666 on the command-line. Hit Counter