, in the form, each input box has a"> How to retrieve input tag corresponding to numeric input type from HTML form using PHP-PHP Chinese Network Q&A
How to retrieve input tag corresponding to numeric input type from HTML form using PHP
P粉563446579
P粉563446579 2023-09-14 16:49:06
0
1
637

I have a form that contains input boxes of type number, each input box has a corresponding label. I'd like to add a "review page" after submitting the form where you can see your answers to each input box (although you don't need to fill out all of them), just like you are sorting the tags. For example, if I write 4 in the input box labeled "Mark Twain", I want to display "Choice 4: Mark Twain". I cannot change the format to Mark Twain

I tried the following code in PHP:

if (isset($_POST["num_a"])) {$a= "Mark Twain"; echo "Choice ", $_POST["num_a"], ":", $a, "
";}

This method works well when num_a is actually input. However, even if num_a is not filled in, it always appears on the review page, so it looks like this:

"Choice: Mark Twain"

What can I do to only display the input box when it has a value? So that only the input box where numbers are entered will appear?

P粉563446579
P粉563446579

reply all (1)
P粉413704245

If the input is empty, the input will not be printed.

if (isset($_POST['num_a']) && $_POST['num_a'] != '') { $a= "Mark Twain"; echo "Choice ", $_POST["num_a"], ":", $a, "
"; }

Since0is not a valid input value, you can simplify to:

if (!empty($_POST['num_a'])) { $a= "Mark Twain"; echo "Choice ", $_POST["num_a"], ":", $a, "
"; }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!