Sunday, March 29, 2009

Exercise 9: Web form design and processing: A basis for e-commerce interaction

1. Design the form

"Retrofit the form data string above for buying some French perfume into the HTML fields and submit button on the web page form.

Code of the form:




Display result of the form:


2. Write the script
Script archive exists for PERL, Python and Javascript. Search the Web for a script that processes the HTML forms data. Read the code and list the steps involoved in processing the form.

The source code to process the form is found in the tutorialspoint.com. It uses the PERL as language to process form at server side.


Figure 1. HTML code from tutorialspoint.com


Figure 2. PERL code from tutorialspoint.com

The first line is the header of the program which locates the PERL interpeter.

The second part is to extract the information from the string from the form and put them into variables.

The string send from the FORM to PERL program after clicking submit:
http://127.0.0.1/cgi-bin/checkout.pl?name=Raymond+TANG&email=ray@hotmail.com&item=French+Perfume&qty=2&paym=VISA&cname=Raymond+Tang&cno=00123456789&submit=Checkout

The final part displays the information according to the user to screen as normal webpage.


3. Can you modify the script to process the form?

The script is modified as follows:


Due to the difference in the platform (Operating System), the starting part (Header) for perl language is changed. The perl interpeter in use is called strawberryperl from strawberryperl.com. It is a perl interpeter for Windows platform. The version I used to run the script is 5.10.0.3.

Result of the trial run with the designed form:



Reference:
TutorialsPoint.com (2009), PERL and CGI Tutorial, Retrieved 8 April 2009 from http://www.tutorialspoint.com/perl/perl_cgi.htm

No comments:

Post a Comment