Introduction to PHP for Os X by Example
Advanced Web Forms
- Its recommend that we create forms in PHP in such a way that they can be seen and edited in a WYSIWYG editor.
- We can use the $_Post or $_GET array to set the value of a form field once the form has been submitted if the form has not been completed correctly and we don’t want the user to have to fill it all out again.
- The echo function (actually a construct) works like the print function. However, unlike print it does not return a value (Print return 1 if successful and 0 if not).
Note: For more info on echo vs. print see http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40.
- When you have a form element that can have multiple values such as a select menu you need to give the form item a name with square brackets at the end e.g.
name="multiples[]". This tells PHP to treat the data as a list.
- We can also use the name with square brackets on items that don’t have multiple values if we want PHP to treat the elements as a list such as a group of related check boxes.
Resources