Navajo Posted February 25, 2009 Share Posted February 25, 2009 Hi guys, <input name="prodass" type="text" id="prodass" value="<?php echo $row2['vchar_assessment_limit'] ?>" size="32" /> I have this text box on my page, I also have this Save button. <FORM METHOD="LINK" ACTION="saveEdit.php?"><INPUT TYPE="submit" VALUE="Save"></FORM> How can I get it so that when saveEdit.php is called the new value of the text box is passed? Quote Link to comment https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/ Share on other sites More sharing options...
KevinM1 Posted February 25, 2009 Share Posted February 25, 2009 Hi guys, <input name="prodass" type="text" id="prodass" value="<?php echo $row2['vchar_assessment_limit'] ?>" size="32" /> I have this text box on my page, I also have this Save button. <FORM METHOD="LINK" ACTION="saveEdit.php?"><INPUT TYPE="submit" VALUE="Save"></FORM> How can I get it so that when saveEdit.php is called the new value of the text box is passed? Well, you have several problems, the biggest of which is your confusion about how values are passed to the script by a form. First, 'link' is not a valid form method. You have two choices - post and get. Post sends values to the server behind the scenes. Get sends values as a query string appended to the end of a URL. In most cases, you want to use post. Sending form values to PHP is ridiculously easy. In your form, simply choose a method (post or get), and give each input a name. Then, in the PHP script (given by the action attribute of the form), you can access your inputs by simply writing: <?php $formInput = $_POST['inputName']; //Or $formInput = $_GET['inputName']; ?> Where inputName is the name you gave your form input in the HTML, and $_POST/$_GET is the form method you used. Quote Link to comment https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/#findComment-770959 Share on other sites More sharing options...
Navajo Posted February 25, 2009 Author Share Posted February 25, 2009 hi, thanks for your reply I now have, <input name="prodass" type="text" id="prodass" value="<?php echo $row2['vchar_assessment_limit'] ?>" size="32" /> </center> <?php $formInput = $_GET['prodass']; ?> <FORM METHOD="LINK" ACTION="viewproductcodes.php"><INPUT TYPE="submit" VALUE="Cancel"></FORM> <?php echo "<FORM METHOD=\"GET\" ACTION=\"saveEdit.php?win=$formInput\"><INPUT TYPE=\"submit\" VALUE=\"Save\"></FORM>" ?> I'm getting Notice: Undefined index: prodass I'm stuck :s Quote Link to comment https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/#findComment-770961 Share on other sites More sharing options...
Navajo Posted February 25, 2009 Author Share Posted February 25, 2009 ok scrap all that <FORM> <center> Product Code: <input name="prodid" type="text" id="prodid" value="<?php echo $productIDCode; ?>" size="32" /><br /><br /> Product Desciption: <input name="proddes" type="text" id="proddes" value="<?php echo $row['vchar_description']; ?>" size="32" /><br /><br /> Assesment Limit: <input type="text" id="prodass" value="<?php echo $row2['vchar_assessment_limit'] ?>" name="prodass" size="32" /> <?PHP $prodass2 = $_POST['prodass']; print ($prodass2); ?> <?php echo "<INPUT TYPE=\"BUTTON\" METHOD=\"GET\" VALUE=\"Save\" ONCLICK=\"window.location.href='saveEdit.php?me=$prodass'\">" ?> </FORM> I keep getting Notice: Undefined index: prodass in E:\Apache2\htdocs\2007\productupdates\editDatabase.php on line 83 Notice: Undefined variable: prodass in E:\Apache2\htdocs\2007\productupdates\editDatabase.php on line 91 help Quote Link to comment https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/#findComment-770992 Share on other sites More sharing options...
premiso Posted February 25, 2009 Share Posted February 25, 2009 $prodass2 = (isset($_POST['prodass']))?$_POST['prodass']:null; Should remove those notices. They are showing up because the form probably has not been posted. This will prevent that error if that is the case. Quote Link to comment https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/#findComment-771000 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.