212
Programming Languages for mis
Listing7.11: PHP Program Writes Data to Disk File on Server (SaveForm.php)
1 <?php
2 print("<html><body>");
3 $lname=$_POST["LName"];
4 $fname=$_POST["FName"];
5 $email=$_POST["Email"];
6 $item=$_POST["Item"];
7 $quant=$_POST["Quantity"];
8 $FileName='FormData.txt';
9 $File=fopen($FileName, 'a+') or die("Cannot open file!");
10 fputs($File, "$lname\r\n");
11 fputs($File, "$fname\r\n");
12 fputs($File, "$email\r\n");
13 fputs($File, "$item\r\n");
14 fputs($File, "$quant\r\n");
15 fclose($File);
16 print("<h2>Thank you for sending the order form!</h2>");
17 print("</body></html>");
18 ?>
In Listing7.11, lines 3 through 7 receive the values of the variables from the form.
Line 8 stores the server file name to the externa ...