Visit the Official PHP Website |
PHP ProgrammingBy James N HitzYour Forms are Ok?It is very common-place to make sloppy or in-complete HTML. Common browsers in the market are too smart and they don't mind. They always fix the probem somehow. Take a look at this: <input type = "text"> This will give you a textbox all right. But you cannot use this textbox with PHP. This is because PHP expects that you at least have a name attribute for each HTML form widget. Remember? To make the above text box "PHP-usable", we will therefore code: <input type ="text" name= "name_here"> And there's more... Some form widgets eg. radio buttons and check boxes that present the same subject MUST share the same name. Let's create an example in which the user supply their marital status: <p>Marital Status: <input type="radio" name ="Mstatus"> Single <input type="radio" name= "Mstatus"> Married <input type="radio" name= "Mstatus"> Widow(ered) <input type = "submit"> That is not all! There are still some more form considerations... See the PHP script executed will not "know" which of the marital statuses was chosen from the three. None has a value! Therefore, apart from assigining a name to each and every form widget, you should also make sure at least the following widgets:...
...have a value attribute assigned to each of them. Revisiting the above buttons on the marital issue: <p>Marital Status:<br> <br><INPUT type="radio" name ="Mstatus" value="Single"> Single <br><INPUT type="radio" name= "Mstatus" value="Married"> Married <br><INPUT type="radio" name= "Mstatus" value="Widow"> Widow(ered) Remember PHP is CASE SeNsiTivE and the names will be used in PHP. If they represent the same issue (as these ones represent the marital status), then they must have the same form of CaPiTaLiZation for the name. Ok. So what happens next? |
JamHitz Productions