Girl Develop It Buffalo

PHP for Beginners Class 3 Exercises

Home

Exercise 2: Let's Fix It!

Create a new file called process-info-1.php and place it in the same folder as form-1.php. Update the form action in our form to process-info-1.php. Rename form.php to form-1.php. Press the Submit button again.

Exercise 3

  1. Go back to your form and enter Maggie May for Full Name and anyone@example.com for Email and click the Submit button.
  2. Copy the text in the URL field of your browser.
  3. Open a new browser tab.
  4. Paste the text you copied into the URL of this new browser tab and hit enter.
  5. In the new tab, change the full name and email to your name and email address and hit enter.
  6. Describe what happens. What happens to the at symbol @ in the URL of the email address field?

Exercise 4

  1. Rename form-1.php to form-2.php.
  2. Rename process-info-1.php to process-info-2.php.
  3. In form-2.php, update the form action to call out to process-info-2.php.
  4. In process-info-2.php, add code to print out both Web Site and Comments.

Exercise 5

Important: use localhost/XAMPP server for this exercise. This may not work on other servers.

Expose the security risk. To do this:

  • In the comments field, enter: <a href="nastysite">A Nasty Site</a>
  • Click the Submit button.
  • Notice what happens.
  • Try changing the link tag and see what happens.
  • Notice that we now have a link on our second/result

Exercise 6

  1. Rename form-2.php to form-3.php.
  2. Rename process-info-2.php to process-info-3.php.
  3. In form-3.php, update the form action to call out to process-info-3.php.
  4. In process-info-3.php, make a call to htmlspecialchars to protect ourselves from nasty input in the Comments text area. Run your program and see what happens. Hint: use the ENT_QUOTES flag.