Provide a server side script
For the purposes of this tutorial, you will use a PHP script to gather the required data, and append it to a text file.
Exactly what transpires on the server is dependent on the needs of the organization collecting the data. A common approach for data collection is to store the form data in a relational database such as DB2®, MySQL, SQL Server, Oracle, and so on. Once the data is in the database, it can be sliced, diced, and analyzed.
For this tutorial, the data is gathered by a PHP script and appended to a text file. Listing 17 shows the PHP form associated with the Robotics registration form.
Listing 17. The Robotic's PHP form
<?php // xmlgui form # 1 // this page is expecting // fname // lname // gender // age $filename = "/pathtowritablefile/datafile.txt"; $f = fopen($filename,"a"); fprintf($f,"Data received @ ".date(DATE_RFC822)); fprintf($f,"\n"); fprintf($f,'First Name:['.$_POST['fname'].']'); fprintf($f,"\n"); fprintf($f,'Last Name:['.$_POST['lname'].']'); fprintf($f,"\n"); fprintf($f,'Gender:['.$_POST['gender'].']'); fprintf($f,"\n"); fprintf($f,'Age:['.$_POST['age'].']'); fprintf($f,"\n"); fclose($f); print "SUCCESS"; ?>
If the script returns the string
RunForm class will reset. Any other value will cause an error message to be displayed to the user and permit them to correct their entries or otherwise obtain help in submitting the form.