PHP Form Complete

1 min read

This chapter shows how to keep the values in the input fields when the user hits the submit button.

Энэ бүлэгт хэрэглэгч оруулах товчийг дарахад оролтын талбар дахь утгыг хэрхэн хадгалахыг харуулсан болно.


PHP – Keep The Values in The Form #

PHP – Үнэт зүйлийг маягтанд хадгалах #

To show the values in the input fields after the user hits the submit button, we add a little PHP script inside the value attribute of the following input fields: name, email, and website. In the comment textarea field, we put the script between the tags. The little script outputs the value of the $name, $email, $website, and $comment variables.

Хэрэглэгч оруулах товчийг дарсны дараа оролтын талбар дахь утгыг харуулахын тулд дараахь оролтын талбаруудын утга шинж чанар дотор бага зэрэг PHP скрипт нэмнэ: нэр, имэйл, вэбсайт. Тайлбар текстийн талбарт бид скриптийг хаягуудын хооронд байрлуулна. Бяцхан скрипт нь $ name, $ email, $ website, $ comment хувьсагчдын утгыг гаргадаг.

Then, we also need to show which radio button that was checked. For this, we must manipulate the checked attribute (not the value attribute for radio buttons):

Дараа нь бид аль радио товчлуурыг шалгасан болохыг харуулах хэрэгтэй. Үүний тулд бид шалгасан атрибуттай ажиллах ёстой (радио товчлуурын утга биш).

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 <input type="radio" name="gender" <?php if (isset($gender) && $gender=="other") echo "checked";?> value="other">Other

Powered by BetterDocs

Leave a Reply