Help newb with entering data into tables

Discussion in 'PHP' started by rcwhite, Dec 28, 2006.

  1. #1
    After i enter data into the email and age threads i get an error saying the not all required fields were entered. Anyone have any ideas?



    
    <?php
    $email = $_POST['email'];
    $age = $_POST['age'];
    
    function addInfo(){
       global $conn;
       $q = "INSERT INTO Info VALUES ('$email', '$age')";
       return mysql_query($q,$conn);
    }
    
    $_SESSION['inforesult'] = addInfo($_POST['email'],$_POST['age']);
    ?>
      
     
    <p>Thank you <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="main.php" title="Login">log in</a>
    </p>
    <html>
    <title>Registration Page</title>
    <body>
    <h1>Please include additional information</h1>
    <form action="<?php echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
    <tr><td>email:</td><td><input type="text" name="email" maxlength="30"></td></tr>
    <tr><td>age:</td><td><input type="int" name="age" maxlength="30"></td></tr>
    <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr>
    </table>
    </form>
    </body>
    </html>
    
    
    
    PHP:

     
    rcwhite, Dec 28, 2006 IP
  2. saidev

    saidev Well-Known Member

    Messages:
    328
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    140
    #2
    "not all required fields were entered" might be from the columns count in your database table, do you have the ddl of the database? are there more than two columns?
     
    saidev, Dec 28, 2006 IP
  3. kajakske

    kajakske Well-Known Member

    Messages:
    139
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    165
    #3
    YOu can try this :

    INSERT INTO Info (email, age) VALUES ('$email', '$age')
     
    kajakske, Dec 29, 2006 IP
  4. etdegraor

    etdegraor Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    How many fields do u have in your datebase??

    If u have only email an age then u can write

    INSERT INTO info (email , age) VALUES ('$email' , '$age')

    if not then the error is becouse of you are not inserting any value into some of your fields which is not NULL!!!:) :)
     
    etdegraor, Dec 29, 2006 IP