www.webdeveloper.com
Results 1 to 3 of 3

Thread: php html post

  1. #1
    Join Date
    Oct 2011
    Posts
    29

    php html post

    if I have the following html in which there is a series of submit buttons and a corresponding text field, which differ only in their names via a counter...

    <form name="form_test" method="post" action="PHP_TEST.php">
    <input type="text" name="input_1"></input>
    <input type="submit" name="submit_1"></input>
    <br>
    <input type="text" name="input_2"></input>
    <input type="submit" name="submit_2"></input>
    <br>
    <input type="text" name="input_3"></input>
    <input type="submit" name="submit_3"></input>
    ...

    I want a php file to be called whenever a sumbit is pressed. My question is how in PHP can I get the value of the corresponding text input whenever its submit button is pressed.

  2. #2
    Join Date
    Feb 2012
    Posts
    218
    PHP Code:
    if($_POST['submit_1']){
     
    // $_POST['input_1']
    }elseif($_POST['submit_2']){
     
    // $_POST['input_2']
    }elseif($_POST['submit_3']){
     
    // $_POST['input_3']


  3. #3
    Join Date
    Oct 2011
    Posts
    29
    Yeah i considered that, but there may be a LOT of these if statements that way. Is there any more simple/elegant way of doing this?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles