php mysql form isset wont work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ukfusion
    New Member
    • Sep 2007
    • 35

    php mysql form isset wont work

    I have a php page with a form....the form has a hidden variable called subjoin. with a value of 1

    in the page the data is posted to i have the following code
    [php]
    <?
    include("includ es/database.php");
    ?>
    <?php
    if(isset($_POST['subjoin'])){
    // ADD A NEW CUSTOMER
    mysql_query("IN SERT INTO details
    (id, customername, companyname, building, street, town, county, postcode, telephone1, telephone2, telephone3, email) VALUES('', '$_POST[customername]', '$_POST[companyname]', '$_POST[building]', '$_POST[street]', '$_POST[town]', '$_POST[county]', '$_POST[postcode]', '$_POST[telephone1]', '$_POST[telephone2]', '$_POST[telephone3]', '$_POST[email]') ")
    or die(mysql_error ());
    echo "New Customer Added";}
    ?>
    [/php]
    i am going to have multiple forms going to this page so i need a way of defining which form has been submitted....bu t what i have above just wont work....have i missed something simple?

    i know this code is probably old or messy but i just want to know what im doing wrong with it.

    thx

    And messy it is. Please enclose any code within the appropriate code tags. See the Posting Guidelines! - moderator
    Last edited by ronverdonk; Feb 27 '08, 04:59 PM. Reason: code within tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Can you not have different names for the submit buttons?
    [php]
    if(isset($_POST['form1']))
    {
    // code for form one
    }
    elseif(isset($_ POST['form2'))
    {
    // code forform 2
    }
    //so on and so forth..
    [/php]

    Comment

    • ukfusion
      New Member
      • Sep 2007
      • 35

      #3
      Originally posted by markusn00b
      Can you not have different names for the submit buttons?
      [php]
      if(isset($_POST['form1']))
      {
      // code for form one
      }
      elseif(isset($_ POST['form2'))
      {
      // code forform 2
      }
      //so on and so forth..
      [/php]
      yeah that works....hmm... ..so why cant i use an input variable.....i just copied that method from another php script and it worked for them...oh well...thanks for that..solves the prob ;0)

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by ukfusion
        yeah that works....hmm... ..so why cant i use an input variable.....i just copied that method from another php script and it worked for them...oh well...thanks for that..solves the prob ;0)
        No problamo!

        Not sure why the other way didn't work.. but this is the more commanly used approach/.

        Comment

        Working...