ICT 5 Web Development - Chapter 9: Maintaining state through multiple forms presents What Are Multiple--Form Web Sessions? How to maintain the state through multiform? PHP Script, Receiving Hidden Fields in Web Sessions. | Vietnam and Japan Joint ICT HRD Program HTTP – stateless protocol HTTP is a stateless protocol Once a web server completes a client's request for a web page, the connection between the two goes away. There is no way for a server to recognize that a sequence of requests all originate from the same client. ICT 5 Web Development Chapter 9. Maintaining state through multiple forms Nguyen Thi Thu Trang trangntt@ 2 Example Multiple Screen Session What Are Multiple-Form Web Sessions? MultipleA multiple-form Web session leads the multipleuser through a series of HTML forms that work together and pass data from form to form. . – To build a shopping cart or on-line survey. on– To save user authentication information from page to page – To store persistent user preferences on a site 3 4 1 How to maintain the state through multiform? Content 1. Hidden fields 2. User browser cookies 3. PHP session Use tricks to keep track of state information between requests (session tracking) – Using hidden form fields – URL rewriting: every local URL on which the user might click is dynamically modified to include extra information – Using cookies: a bit of information that the server give to a client depends on the client – Using session 5 1. Hidden fields 6 A Full Script Example Hidden fields are part of HTML forms – Not displayed but value can be accessed in receiving script like any other variable. Consider an example script sets a hidden fi ld hidd field – Implements the Order Info form – on submit sends data to – Can still be viewed by user’s who view source. 7 8 2 PHP Script – The Output . 1. 2. 3. 4. 5. 6. 7. 8. Order Product p p p Hardware Product Order Form We have hammers, handsaws, and wrenches on special today! name="sample_hidden" Enter Enter Item: 9. Enter Quantity: maxlength="20" name="quantity"> 10. 12. The previous code can be executed .