Announcement

Collapse
No announcement yet.

Inserting inputted data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inserting inputted data

    I have this registration form im creating and was wondering how do i query so that what the user has inputted into the input box will be inserted to the table. I have this so far:



    <?php
    // Make a MySQL Connection
    mysql_connect("localhost", "test", "test1") or die(mysql_error());
    mysql_select_db("testdatabase") or die(mysql_error());

    // Insert a row of information into the table "registrationdetails"
    mysql_query("INSERT INTO registrationdetails
    (Username) VALUES("What goes here") ?


    **
    I created the input box on a form in my html page. Now i wanted to know how do i know what to put after VALUES to make it insert the inputted data from the user to the row? is it sumin like "VALUES("editbox.name") ??

    *Also how do i know which property it is in bluevoda to name the editbox to make it unique to all the other edit boxes on my registration page so i know which edit box i want to use to insert data to the table?

    thanks to any help you can give

  • #2
    Re: Inserting inputted data

    You will need to do something like...

    $username = $_POST['username'];
    $password = $_POST['password'];

    $insert = mysql_query("INSERT INTO table (username, password) VALUES ('$username', '$password')");

    Now you will also want check that the username doesn't contain characters like ' or ", which can be used with sql injection (hacks into your site).

    You will also want to encrypt your password with either md5() or sha1(), you don't want plain text passwords stored anywhere on the internet (that includes files on the server, ie databases).

    You want edit the "name" attribute of html form elements, that corresponds to the inside of $_POST[' '], (stuff in between ' ')

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment

    Working...
    X