CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2007
    Posts
    40

    Post several html forms POST to one .php file

    hello!

    I've created this small PHP script, which, when loaded, takes a table from a mysql database and outputs all its lines to the browser window - like a custom blog. When the script is doing that, I would like to generate a form for each of the rows that would contain a button and a hidden field, which would store the records unique ID key from the db. How could I make the other .php script understand which of those fors I clicked the submit button on. thanks!

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: several html forms POST to one .php file

    Create a hidden input in the forms that submit to the one page. Then, use that hidden input's value to tell the one PHP file which way to process the form.

    PHP Code:
    <?php
    $form 
    $_POST['form'];

    if (
    $form == 'addressbook') {
      
    // process the address book form
    }
    if (
    $form == 'otherexample') {
      
    // process another example
    }
    ?>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2007
    Posts
    40

    Re: several html forms POST to one .php file

    yeah, sure, but the forms are auto-generated by the script that selects table rows from the mysql table. the code below is generated:

    Code:
    <table border="0"><table width="100%"><tr><td><dl class="curved"><dt>This is a test post</dt><dd><p><b>When:</b> 2008-09-18 @ 14:28:42</br>-----------------</br></p><p class="last">Paskaties virsrakstu</p></dd><form method="POST" action="comments.php"><input type="hidden" value="11" name="wacko"11><input type="submit" name="submitit11" value="Add/View comments"></form></dl></td></tr></table><table width="100%"><tr><td><dl class="curved"><dt>Online at Last!</dt><dd><p><b>When:</b> 2008-09-18 @ 07:56:44</br>-----------------</br></p><p class="last">Nu ko, beidzot mans pirmais blogs ir onlainā. Beta tas ir tāpēc, ka es savu bloga sistēmu pats uzcepu un turpināšu cept. Nu šis ir pirmais variants, varam gaidīt izmaiņas.
    
    Par ko rakstīšu. Nu principā iemetīšu šeit savas pārdomas, naidu, priekus, viedokli, jaunumus u.c. lietas. Rakstīšu bez cenzūras un cik nu godīgi vien iespējams. Paldies par uzmanību.</p></dd><form method="POST" action="comments.php"><input type="hidden" value="10" name="wacko"10><input type="submit" name="submitit10" value="Add/View comments"></form></dl></td></tr></table></table>
    so you can see that I would like to get the data from one certain form, say for opening a new page, where I could then write a comment to the post.

  4. #4
    Join Date
    Dec 2007
    Posts
    40

    Re: several html forms POST to one .php file

    d'oh .... nevermind. the above code is working

  5. #5
    Join Date
    Dec 2007
    Posts
    5

    Re: several html forms POST to one .php file

    *ROFL*

    bad happens...

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured