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 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Inserting Data (Mysql)

    Can Someone show me how exactly I am supposed to make it so that and html code or php. w/e inserts a username password and other stuff into the database?

  • #2
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    google can show you millions of ways.

    this is from
    http://www.tizag.com/mysqlTutorial/mysqlinsert.php
    and will get you started

    PHP Code:
    <?php
    // Make a MySQL Connection
    mysql_connect("localhost""admin""1admin") or die(mysql_error());
    mysql_select_db("test") or die(mysql_error());

    // Insert a row of information into the table "example"
    mysql_query("INSERT INTO example 
    (name, age) VALUES('Timmy Mellowman', '23' ) "

    or die(
    mysql_error());  

    mysql_query("INSERT INTO example 
    (name, age) VALUES('Sandy Smith', '21' ) "

    or die(
    mysql_error());  

    mysql_query("INSERT INTO example 
    (name, age) VALUES('Bobby Wallace', '15' ) "

    or die(
    mysql_error());  

    echo 
    "Data Inserted!";

    ?>

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hmm .. im having issues..

    Account.html Page:

    <html>
    <head>
    </head>
    <title>
    </title>
    <body>
    <body>
    <h4>Account Page</h4>
    <form action="login.php" method="post">
    Username: <input type="text" size="10" maxlength="40" name="username"> <br />
    Password: <input type="password" size="10" maxlength="10" name="password">
    date of birth: <input type="text" size="10" maxlength="40" name="dob"> <br />
    Country: <input type="text" size="10" maxlength="40" name="country"> <br />
    Gender: <input type="text" size="10" maxlength="40" name="gender"> <br />
    <input type="submit" />
    </form>
    </body>
    </body></html>



    login.php page (account creation):

    <html><body>
    <?php
    // Make a MySQL Connection
    mysql_connect("localhost", "root", "password") or die(mysql_error());
    mysql_select_db("accounts") or die(mysql_error());

    // Insert a row of information into the table "example"
    mysql_query("INSERT INTO example
    (userid, username, password, country, ip, gender, dob) VALUES('+1', 'username', 'password', 'date of birth', 'country', 'gender' ) ")
    or die(mysql_error());

    echo "Data Inserted!";

    ?>
    </body></html>

    ...

    can someone help me?

  • #4
    New Coder
    Join Date
    Aug 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Attached Thumbnails Attached Thumbnails Inserting Data (Mysql)-database.jpg  

  • #5
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by jdfskitz View Post
    can someone help me?
    Yes: state your problem. "im having issues" is a lousy problem description.
    Are you a Help Vampire?

  • #6
    New Coder
    Join Date
    Aug 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts
    make the code to create accounts into my database and show me how to fix my code...

  • #7
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by jdfskitz View Post
    make the code to create accounts into my database and show me how to fix my code...
    I think it's too soon for you to jump into this project, if you don't know what your problem is, and where it's located.
    You need to understand the code first.

    I'd suggest you to read the HTML tutorials first and then PHP on e.g. w3schools. Take it one step at a time, and it'll be a piece of cake afterwards.


  •  

    Posting Permissions

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