13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

368 Chapter 16 <strong>Web</strong> Application Security<br />

<br />

<br />

What be ye laddie? <br />

<br />

<br />

<br />

Male<br />

Female<br />

None of your Business<br />

<br />

<br />

<br />

<br />

This form could look as shown in Figure 16.1. Given this form, we might assume that<br />

whenever we query the value of $_POST['gender'] in submit_form.php, we are going to get<br />

one of the values 'Male', 'Female', or 'Other'—<strong>and</strong> we would be completely wrong.<br />

Figure 16.1<br />

A trivial little gender entry form.<br />

As we mentioned previously, the <strong>Web</strong> operates using HTTP, a simple text protocol.The<br />

preceding form submission would be sent to our server as a text message with a structure<br />

similar to the following:<br />

POST /gender.php HTTP/1.1<br />

Host: www.yourhostname.com<br />

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1)<br />

Gecko/2008070208 Firefox/3.0.1<br />

Content-Type: application/x-www-form-urlencoded<br />

Content-Length: 11<br />

gender=Male

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!