Form Input Not Working? |
Form Input Not Working? |
Rayj00 |
Mar 22 2024, 09:28 AM
Post
#1
|
Group: Members Posts: 6 Joined: 1-June 20 Member No.: 27,369 |
I have a form with 20 inputs. They all work except one.
By work I mean subsequently, a php script can read the $_POST and update a mySQL database. But the following one is not working, as the subsequent $_POST is empty? For some reason the html looks like it's not working. I have the following html: <li id="li_15" > <label class="description" for="element_15">Property Identification Number: </label> <div> <input id="element_15" class="myDiv" type="text" maxlength="30" name='propertypin' Required /> </div> </li> The subsequent $propertypin = ($_POST['propertypin']); echo ("\n<h2>Propertypin = $propertypin </h2>\n"); returns nothing, while the other 19 $_POST's are fine. This is pretty simple stuff but I am pulling my hair trying to fix it!! Any ideas? Thanks, Ray |
Christian J |
Mar 22 2024, 11:52 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,743 Joined: 10-August 06 Member No.: 7 |
The following works for me:
CODE <form method="post"> <ul> <li id="li_15" > <label class="description" for="element_15">Property Identification Number: </label> <div> <input id="element_15" class="myDiv" type="text" maxlength="30" name='propertypin' Required /> </div> </li> </ul> <input type="submit" value="Send"> </form> <?php $propertypin = ($_POST['propertypin']); echo ("\n<h2>Propertypin = $propertypin </h2>\n"); ?> (of course you should sanitize the POST data before using it in a database query, or even writing it to a web page). What do the other INPUT fields look like? Do you have more than one with the same NAME "propertypin"? |
James Goff |
Yesterday, 03:40 AM
Post
#3
|
Group: Members Posts: 2 Joined: Yesterday, 03:36 AM Member No.: 29,306 |
QUOTE I have a form with 20 inputs. They all work except one. By work I mean subsequently, a php script can read the $_POST and update a mySQL database. But the following one is not working, as the subsequent $_POST is empty? For some reason the html looks like it's not working. I have the following html: <li id="li_15" > <label class="description" for="element_15">Property Identification Number: </label> <div> <input id="element_15" class="myDiv" type="text" maxlength="30" name='propertypin' Required /> </div> </li> The subsequent $propertypin = ($_POST['propertypin']); echo ("\n<h2>Propertypin = $propertypin </h2>\n"); returns nothing, while the other 19 $_POST's are fine. This is pretty simple stuff but I am pulling my hair trying to fix it!! Any ideas? Thanks, Hello, The HTML and PHP code snippets you've shared seem correct. Here are a few suggestions to troubleshoot: Check for Typos: Ensure there are no typos in the name attribute of the input field. Inspect Form Tags: Ensure the <form> tag properly wraps your inputs and has the correct method="post" attribute. Verify Form Submission: Ensure that the form is correctly submitting data. Add a basic debug statement to check all $_POST values. Check for Duplicates: Ensure no other input shares the same name attribute. Try adding this debug code at the top of your PHP script to see all submitted values: php print_r($_POST Best Regards, James Goff |
Lo-Fi Version | Time is now: 4th December 2024 - 04:27 AM |