Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem inserting form info into mysql database

    <form method=\"post\" action=?=$PHP_SELF">
    <pre>
    <?php if(!$username|| !$pass || !$pass2 || !$email)
    echo "Please fill out all fields";
    echo "<br>";
    <br>
    Username:
    <input type="text" name="uname" size="15" value="<?php echo $username?>">
    <br>Password:
    <input type="text" name="email" size="30"><br>
    <input type="submit" name="submit" value="submit">
    <pre>
    <br>
    Username:
    <input type="text" name="uname" size="15" value="<?php echo $username?>">
    <br>Password:
    <input type="text" name="email" size="30"><br>
    <input type="submit" name="submit" value="submit">
    </pre>


    </form>

    </body>

    </html>
    <?php

    $db= mysql_connect("localhost","root","");
    mysql_select_db("kgazette");

    if($submit) {
    $query=("insert users uname,passwd,email values ('$uname','$passwd','$email')");
    mysql_query($query);
    $result=mysql_query($query);
    echo "You are now registered";
    } else {
    echo "There was some problems with your Registration form please contact your Ad
    ministrator";
    }
    ?>
    Last edited by gkelly; 09-20-2005 at 05:22 PM. Reason: changed

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    A couple of hints - use the [ PHP ] tags around your code - it makes it easier to read, and secondly, try explaining the problem rather than just posting the code, along with any error messages you are getting.

    I think the problem is this line :
    PHP Code:
    $query=("insert users uname,passwd,email values ('$uname','$passwd','$email')"); 
    change it to
    PHP Code:
    $query=("INSERT INTO users (uname,passwd,email) VALUES ('$uname','$passwd','$email')")or die(mysql_error()); 

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks having problem inserting more then one record

    Thanks for the quick response, now the problem I am having is it inserts only one record if, I go to the screen and try to create another user, it will not insert another user any ideas.

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    are you getting any error messages?
    Are you trying to insert a record with the same values in a 'unique' field?

  • #5
    New Coder
    Join Date
    Jun 2005
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks for all your help I figured out the problem it was just that.


  •  

    Posting Permissions

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