Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/146852-passing-a-text-field-as-a-variable/
Share on other sites

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.

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

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 :(

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.