#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    4
    Rep Power
    0
    i copied & paste an example from webmonkey and get this error on th browser:

    'Warning: Uninitialized variable or array index or property (submit) in /home/httpd/html/php/dbform3.php3 on line 4'

    the code:
    <html>
    <body>
    <?php
    if ($submit) {
    // process form
    $db = mysql_connect("localhost", "root","trickle");
    mysql_select_db("mydb",$db);
    $sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";
    $result = mysql_query($sql);

    echo "Thank you! Information entered.n";
    } else{

    // display form
    ?>

    <form method="post" action="<?php echo $PHP_SELF?>">
    First name:<input type="Text" name="first"><br>
    Last name:<input type="Text" name="last"><br>
    Address:<input type="Text" name="address"><br>
    Position:<input type="Text" name="position"><br>
    <input type="Submit" name="submit" value="Enter information">
    </form>

    <?php
    } // end if
    ?>

    </body>
    </html>


    how do I get rid off the warning message?

    tia.
  2. #2
  3. No Profile Picture
    worshipper of DOT
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Halmstad, Sweden
    Posts
    35
    Rep Power
    15
    The reason you get the error is that the first time you fire up the script, the $submit-variable isn't set ..

    try

    if (isset($submit))

    instead ..

    forgive if i'm totally wrong ..



    ------------------
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Linux, the operating system with a clue - Command Line User Environment.[/quote]

    geeee... thanks!

    /closecut
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    4
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by closecut:
    The reason you get the error is that the first time you fire up the script, the $submit-variable isn't set ..

    try

    if (isset($submit))

    instead ..

    forgive if i'm totally wrong ..


    [/quote]

    COOL. it works.

    thanks.

Similar Threads

  1. Replies: 4
    Last Post: February 13th, 2004, 03:31 PM
  2. A variable $_POST variable?
    By CLuver in forum PHP Development
    Replies: 0
    Last Post: February 11th, 2004, 12:55 AM
  3. How to read multiple line text file into a variable
    By gatewaycityca in forum Visual Basic Programming
    Replies: 4
    Last Post: January 29th, 2004, 12:26 PM
  4. Replies: 5
    Last Post: November 16th, 2003, 11:31 AM
  5. How to grab Javascript form variable into a PHP Variable
    By dfroehli in forum JavaScript Development
    Replies: 3
    Last Post: October 1st, 2003, 08:21 PM

IMN logo majestic logo threadwatch logo seochat tools logo