[http://creativecommons.org/licenses/by/3.0/]
This work is licensed under a CC
Attribution 3.0 Unported License [http://creativecommons.org/licenses/by/3.0/]
The vast majority of web sites today are no longer static HTML pages but database-driven web applications. Today we'll look at a simple database-driven web application in detail, to see how its various components--HTML forms, application server, and database--work together.
<form action="http://stevex.net/dump.php" method="POST" enctype="multipart/form-data"><table> <tr><td>Text:</td><td><input type="text" name="text" value="text input"/></td></tr> <tr><td>Password:</td><td><input type="password" name="password" value="hidden text"/></td></tr> <tr><td>Checkbox:</td><td><input type="checkbox" name="check" value="1"/> <input type="checkbox" name="check" value="2"/> <input type="checkbox" name="check" value="3"/></td></tr> <tr><td>Radio Button:</td><td><input type="radio" name="radio" value="1"/> <input type="radio" name="radio" value="2"/> <input type="radio" name="radio" value="3"/></td></tr> <tr><td>Text Areas:</td><td><textarea name="textarea" rows="2" cols="20"/></td></tr> <tr><td>Selection:</td><td><select name="select"><option selected="selected">XML</option><option>SGML</option></select></td></tr> <tr><td>Multiple Selection:</td><td><select name="mselect" multiple="multiple"><option>242</option><option>290-3</option><option>290-13</option></select> <tr><td>File Upload:</td><td><input name="file" type="file"/></td></tr> <tr><td valign="top" align="right">Hidden:</td><td><input type="hidden" name="hidden" value="hidden input"/></td></tr> <tr><td>Submit:</td><td><input name="submit" type="submit"/></td></tr> </table></form>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>JavaScript Datepicker</title> <script type="text/javascript" src="date-picker.js"></script> <link rel="stylesheet" type="text/css" href="date-picker.css"> </head> <body> <form action="http://stevex.net/dump.php" method="GET"> <input type="text" name="date"> <input type="button" value="calendar" onclick="displayDatePicker('date');"> <input type="submit" value="submit date"> </form> </body> </html>
POST
)GET
is good!GET
when implementing a form that isn't changing dataGET
encodes the values in the URIPOST
request method can upload dataPOST
sends a request containing an entityPOST
is used if the form specifies itapplication/x-www-form-urlencoded
is the default (values in the entity)multipart/form-data
is required for file upload (multipart form data)POST
requestsGET
/POST
transparentlyGET
POST
POST
with multipart/form-data
<p>Query Parameter Test:</p> <p>test: <?php echo $_REQUEST["test"]; ?></p> <p>name: <?php echo $_REQUEST["name"]; ?></p> <p>field: <?php echo $_REQUEST["field"]; ?></p>
<tr><td>Text:</td><td><input type="text" name="text"/></td></tr> <tr><td>Password:</td><td><input type="password" name="password"/></td></tr>
<tr> <td><label for="textctrl">Text:</label></td> <td><input type="text" name="text" id="textctrl"/></td> </tr> <tr> <td><label for="pwdctrl">Password:</label></td> <td><input type="password" name="password" id="pwdctrl"/></td> </tr>