{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

PHP - Part 5 - Form Handling - CIS 4004 Web-Based...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 4004: PHP – Part 5 – Form Handling Page 1 Dr. Mark Llewellyn © CIS 4004: Web-Based Information Technology Spring 2011 Introduction to PHP – Part 5 – Form Handling Department of Electrical Engineering and Computer Science University of Central Florida Instructor : Dr. Mark Llewellyn [email protected] HEC 236, 407-823-2790 http://www.cs.ucf.edu/courses/cis4004/spr2011
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CIS 4004: PHP – Part 5 – Form Handling Page 2 Dr. Mark Llewellyn © Form Handling In PHP This set of notes will focus on handling forms in PHP. If you need a refresher on generating forms and the various XHTML elements that might appear in a form, I suggest you go back and review the XHTML notes Advanced XHTML & CSS – Tables And Forms that we covered earlier in the course. What we want to do here is focus on the PHP side of things and not the XHTML side. Recall in the earlier set of notes that when we created a form, the action attribute simply caused an email to be sent to the address specified by the action attribute. What we want to do here though is cause a PHP script to be executed and the data from the form made available to the script.
Image of page 2
CIS 4004: PHP – Part 5 – Form Handling Page 3 Dr. Mark Llewellyn © Form Handling In PHP Depending on what method was used to submit the form data to the PHP script (either GET or POST), PHP has two superglobal arrays , called $_GET and $_POST , that will be used to store the data contained in the form. $_GET and $_POST are associative arrays that contain, as key values, the names of the form elements as specified by their name attribute and their associated values as submitted by the user. You may recall that we saw an example of this in the introductory set of PHP notes. That example is duplicated on the next two pages to refresh your memory. Note: The term superglobal refers to variables that are generated by the PHP and are always in scope. This means that regardless of where you are in a PHP script, whether it be inside a function or elsewhere, a superglobal variable is always available without needing to use the global statement to bring the variable into the current scope.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CIS 4004: PHP – Part 5 – Form Handling Page 4 Dr. Mark Llewellyn © Form Handling In PHP XHTML document
Image of page 4
CIS 4004: PHP – Part 5 – Form Handling Page 5 Dr. Mark Llewellyn © Form Handling In PHP PHP script
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CIS 4004: PHP – Part 5 – Form Handling Page 6 Dr. Mark Llewellyn © Form Handling In PHP For reasons of internationalization, get has been deprecated as a value for the method attribute in XHTML form elements. So we will focus exclusively on the post value for the method attribute and thus the $_POST superglobal array. In earlier versions of PHP (those prior to 4.1.0), PHP created, by default, standard variable names to represent the values contain within the superglobal arrays. Current versions, by default, do not enable this property for security reasons. It is still possible to turn this behavior on by setting the register_globals directive to on in the PHP configuration file ( php.ini ), it should be discouraged.
Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern