====== Web Development Lesson 8 - Forms ====== ===== Posting Data ===== ==== Objective ==== In this activity you will learn an alternative way to send data to another page. ==== Setup ==== * We'll continue using 'form.php' and 'process_form.php' in this activity. Here is the code again if you need it. **form.php** prepare($query); $hrslt->execute($args); // get list of movies $query = "SELECT movie FROM appearances GROUP BY movie"; $args = array(); $mrslt = $pdo->prepare($query); $mrslt->execute($args); ?>
Add Hero
    • Hero
    • Villain
Add Appearances
    • fetch()) { ?>
**process_form.php**

You have chosen

==== POST ==== * Open 'form.php' in your browser and check all boxes in the second form. * Add 'Avengers: Age of Ultron' as the new movie title. * Click 'Add Appearance'. * Now look at the URL. * It's very long because of all the information included. * This may not be a problem, but if you are including a password or other information that the user may not want visible to others, this isn't secure. * Instead, change the method of your forms to post.
... * Save and upload the file and do the same as above. * The URL looks much cleaner now, but we need to access the information. * Posted data is stored in the variable '$_POST'. * Print it out using print_r to ensure it's there.

* Refresh the page and you'll see the data you've sent listed in a line. * To view this in a more readable format, right click and select 'View Page Source'. [[en:web_development:forms:insert|Next: INSERT Queries]]