With HTML Forms We Will Present Tow Methods of Transmittion Data to the Server

With HTML Forms We Will Present Tow Methods of Transmittion Data to the Server

<p> Server Side Programming with PHP CPAN 542</p><p>Lecture 4: Forms</p><p>In HTML forms, method represents how the data will be sent to the server (Get or Post) and action represents the URL of the program that will process the form data (for example, it might be a CGI program, ASP, JSP or servlet). Also, for post method, you can only specify an email address where the form data will be sent. For example <form name=”form” method=”post” action=”mailto:[email protected]?sebject=form data:”> where [email protected] represents your email address on the HAL server. When you use forms, the method attribute specifies how the data will be transmitted to the server. Using the get method results in the data being appended to the end of the action URL after a question mark in the form: name1=value1&name2=value2&…. When post is used, the data is embedded in the HTTP request in a separate line, and it is available to a java program as standard input. get method is easer to work with since you do not need a form to debug your server side code as you can type the server side program URL and append the data to it after question mark . Get method is not recommended when the information you want to send is sensitive (like account numbers and passwords). In addition to that you are limited to 255 characters. The disadvantage of post method is that a Java applet cannot display a page or read from the post program on a host other than the applet’s host. Example: form_feedback.html In this example we will design the following feedback form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Feedback page</title> </head> <body bgcolor="#CCFFCC"> <form method="get" action="mailto:[email protected]?subject=form data"> <table summary="This table shows form elements" border="1" width="68%" height="343"> <tr> <td width="52%" height="23" align="right">Title:</td> <td width="70%" valign="middle" height="23"> <select size="1" name="titles"> <option selected="selected">Mr.</option> <option>Ms.</option> <option>Mrs.</option> </select></td> </tr> <tr> <td width="52%" height="23" align="right">Name:</td> <td width="70%" height="23"> <input type="text" name="Name" size="42" /></td> </tr> <tr> <td width="52%" height="23" align="right">Phone (Optional):</td> <td width="70%" height="23"><input type="text" name="Phone" size="25" /></td> </tr> <tr> <td width="52%" height="23" align="right">Email Address:</td> <td width="70%" height="23"> <input type="text" name="Email" size="53" /></td> </tr> <tr> <td width="52%" height="18" align="right"> <p align="left">Which format do you like the most:</p> </td> <td width="70%" height="18"><input type="checkbox" name="preferrences" value="Framed" />Framed <input type="checkbox" name="preferrences" value="Frameless" />Frameless <input type="checkbox" name="preferrences" value="Tabular Framed" />Tabular Framed</td> </tr> <tr> <td width="52%" height="19" align="right"> <p align="center"> How would you like to receive news about my web site: </p> </td> <td width="70%" height="19"> <table summary="This inner table group radio buttons" border="1" width="100%"> <tr> <td width="25%"><input type="radio" value="mail" name="respond" />Mail</td> <td width="25%"> <input type="radio" value="email" name="respond" />Email </td> <td width="25%"><input type="radio" value="phone" name="respond" />Phone </td> <td width="25%"> <input type="radio" value="none" checked="checked" name="respond" />None</td> </tr> </table> </td> </tr> <tr> <td width="52%" height="226" align="right"> <p align="center">Please insert a short comment here:</p> </td> <td width="70%" height="226"><textarea rows="9" name="Comments" cols="43"></textarea></td> </tr> </table> <p><input type="submit" value="Submit" /><input type="reset" value="Reset" /></p> </form> </body> </html> Upload this form to your account on the HAL server and make a link from your index page to this form.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us