Variables not passing from html file to php file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Wilcox

    Variables not passing from html file to php file

    I have the following two files used to insert data into a database. when
    meinsert.php is executed a blank record is inserted in the database as if
    the .php file is not receiving the variables.

    Any ideas why this might be happening? Environment is stock RH9 with no
    updates. I believe it is PHP 4.2.2 and Apache 2.0.40.

    Thanks,

    Mike

    meinsert.html
    <html>
    <body>
    <form action="meinser t.php" method="post">
    Last Name: <input type="text" name="lastname" ><br>
    His Name: <input type="text" name="hisname"> <br>
    Her Name: <input type="text" name="hername"> <br>
    Address: <input type="text" name="address"> <br>
    City: <input type="text" name="city"><br >
    State: <input type="text" name="state"><b r>
    Zip: <input type="text" name="zip"><br>
    Phone Number: <input type="text" name="phone"><b r>
    Email: <input type="text" name="email"><b r>
    Weekend Date: <input type="date" name="WkEndDate "><br>
    Wedding Date: <input type="text" name="weddate"> <br>
    Referred By: <input type="text" name="referred" ><br>
    Prayer Couple: <input type="text" name="prayercou ple"><br>
    Paid: <input type="text" name="paid"><br >
    Area: <input type="text" name="area"><br >
    <input type="submit" value="SUBMIT"> <br>
    </form>
    </body>
    </html>

    meinsert.php
    <html>
    <head>
    <title>Insert Couple to Database</title>
    </head>
    <body>

    <?php

    //connect to database server
    $dbcnx = @mysql_connect( "localhost" , "root", "password") ;

    if (!dbcnx) {
    echo( "<p>Unable to connect to the database server.<p>");
    exit();
    }

    if (! @mysql_select_d b("ME") ){
    echo ( "<p>Unable to locate the ME database.</p>" );
    exit ();
    }
    echo ("Adding Couple");
    //if ($submitcouple == "SUBMIT"){
    echo ("getting here!<br>");
    $sql = "INSERT INTO Couples SET
    LastName = '$lastname',
    HisName = '$hisname',
    HerName = '$hername',
    Address = '$address',
    City = '$city',
    State = '$state',
    Zip = '$zip',
    Phone = '$phone',
    eMail = '$email',
    WkEndDate = '$WkEndDate',
    WeddingDate = '$weddate',
    Referred = '$referred',
    PrayerCouple = '$prayercouple' ,
    Paid = '$paid',
    Location = '$area'";

    if (@mysql_query($ sql)){
    echo ( "<p> " . $hisname . "and " . $hername . "have been added to the
    database.</p>");
    }else{
    echo ("<p>Error adding couple to the database: " . mysql_error() .
    "</p>");
    }

    //}

    ?>
    </body>
    </html>


  • Gary Petersen

    #2
    Re: Variables not passing from html file to php file

    A horsie named Mike Wilcox demonstrated surprising intelligence and its
    ability to use morse code on Tue, 09 Sep 2003 23:07:55 -0500 when it
    tapped <vsx7b.407198$H o3.61795@sccrns c03> with its hoof:
    [color=blue]
    > I have the following two files used to insert data into a database. when
    > meinsert.php is executed a blank record is inserted in the database as
    > if the .php file is not receiving the variables.
    >
    > [...]
    >
    > echo ("Adding Couple");
    > //if ($submitcouple == "SUBMIT"){
    > echo ("getting here!<br>");
    > $sql = "INSERT INTO Couples SET
    > LastName = '$lastname',[/color]

    Try:
    LastName = '_$POST[lastname]',

    The register_global s option is probably off.

    Comment

    • Marcin Dobrucki

      #3
      Re: Variables not passing from html file to php file


      My money is on the fact that you have global variables turned off.

      /Marcin

      Mike Wilcox wrote:[color=blue]
      > I have the following two files used to insert data into a database. when
      > meinsert.php is executed a blank record is inserted in the database as if
      > the .php file is not receiving the variables.
      >
      > Any ideas why this might be happening? Environment is stock RH9 with no
      > updates. I believe it is PHP 4.2.2 and Apache 2.0.40.
      >
      > Thanks,
      >
      > Mike
      >
      > meinsert.html
      > <html>
      > <body>
      > <form action="meinser t.php" method="post">
      > Last Name: <input type="text" name="lastname" ><br>
      > His Name: <input type="text" name="hisname"> <br>
      > Her Name: <input type="text" name="hername"> <br>
      > Address: <input type="text" name="address"> <br>
      > City: <input type="text" name="city"><br >
      > State: <input type="text" name="state"><b r>
      > Zip: <input type="text" name="zip"><br>
      > Phone Number: <input type="text" name="phone"><b r>
      > Email: <input type="text" name="email"><b r>
      > Weekend Date: <input type="date" name="WkEndDate "><br>
      > Wedding Date: <input type="text" name="weddate"> <br>
      > Referred By: <input type="text" name="referred" ><br>
      > Prayer Couple: <input type="text" name="prayercou ple"><br>
      > Paid: <input type="text" name="paid"><br >
      > Area: <input type="text" name="area"><br >
      > <input type="submit" value="SUBMIT"> <br>
      > </form>
      > </body>
      > </html>
      >
      > meinsert.php
      > <html>
      > <head>
      > <title>Insert Couple to Database</title>
      > </head>
      > <body>
      >
      > <?php
      >
      > //connect to database server
      > $dbcnx = @mysql_connect( "localhost" , "root", "password") ;
      >
      > if (!dbcnx) {
      > echo( "<p>Unable to connect to the database server.<p>");
      > exit();
      > }
      >
      > if (! @mysql_select_d b("ME") ){
      > echo ( "<p>Unable to locate the ME database.</p>" );
      > exit ();
      > }
      > echo ("Adding Couple");
      > //if ($submitcouple == "SUBMIT"){
      > echo ("getting here!<br>");
      > $sql = "INSERT INTO Couples SET
      > LastName = '$lastname',
      > HisName = '$hisname',
      > HerName = '$hername',
      > Address = '$address',
      > City = '$city',
      > State = '$state',
      > Zip = '$zip',
      > Phone = '$phone',
      > eMail = '$email',
      > WkEndDate = '$WkEndDate',
      > WeddingDate = '$weddate',
      > Referred = '$referred',
      > PrayerCouple = '$prayercouple' ,
      > Paid = '$paid',
      > Location = '$area'";
      >
      > if (@mysql_query($ sql)){
      > echo ( "<p> " . $hisname . "and " . $hername . "have been added to the
      > database.</p>");
      > }else{
      > echo ("<p>Error adding couple to the database: " . mysql_error() .
      > "</p>");
      > }
      >
      > //}
      >
      > ?>
      > </body>
      > </html>
      >
      >[/color]

      Comment

      Working...