PHP Form Validation - Kompleto na Halimbawa ng Form

Ito ang pinapakita sa Seksyon na ito kung paano panatilihin ang halaga sa mga lapag ng input pagkatapos na isumite ng user ang form.

PHP - Panatilihin ang Halaga ng Form

Kung gusto mong ipakita ang halaga sa input na lapag pagkatapos na i-click ang pindutan ng sumite ng user, kami ay nagdagdag ng isang maliit na script ng PHP sa value na katangian ng input na lapag: name, email at website. Sa comment na text box na lapag, kami ay inilagay ang script sa gitna ng <textarea> at </textarea>. Ang mga script na ito ay naglalabas ng halaga ng mga variable na $name, $email, $website at $comment.

Then, we also need to display which radio button is selected. For this, we must operate the checked attribute (not the value attribute of the radio button):

Name: <input type="text" name="name" value="<?php echo $name;?>">
E-mail: <input type="text" name="email" value="<?php echo $email;?>">
Website: <input type="text" name="website" value="<?php echo $website;?>">
Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
Gender:
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="female") echo "checked";?>
value="female">Female
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="male") echo "checked";?>
value="male">Male

PHP - Complete Form Example

Below is the complete code for the PHP form validation example:

Example

Run Instance