Jump to content

[SOLVED] submitting multiple entries into a sql database


sudsy1970

Recommended Posts

hi all,

 

I have a register form on my website and I want to transfer the details to a database.  The trouble is I can't seem to get it to work.

 

I am trying to just enter the $_POST data from the form, is this right?

 

I can connect to the database, but can't get the information into the database.

 

Here is my code:

 

            $sql = "INSERT into users";
            $sql.= "VALUES \""$_POST.['Firstname']."\",\""$_POST.['Surname']."\"";
            \""$_POST.['Email']."\",\""$_POST.['Dob']."\",\""$_POST.['Password1']."\"\""$_POST.  ['User']."\";

 

Cheers for any help

 

sudsy

1) You need to specify what fields you're inserting into BEFORE the VALUES. 

2) The POST calls are the wrong syntax (you need to take out the periods). 

3) You're not executing the mysql_query.

4) I think your code looks very sloppy, let me help you out.

 

$Firstname = $_POST['Firstname'];
$Surname = $_POST['Surname'];
$Email = $_POST['Email'];
$Dob = $_POST['Dob'];
$Password1 = $_POST['Password1'];
$User = $_POST['User'];

mysql_query("INSERT into users (Firstname, Surename, Email, Dob, Password1, User)
                        VALUES ('$Firstname', '$Surename', '$Email', '$Dob', '$Password1', '$User') ") 
                        or die(mysql_error());  

 

Please check out this tutorial on the basics on INSERT, Tizag - INSERT

Cool, it almost works. That's great mate cheers code is sloppy as i am just learning this php thing.

 

i wasn't sure if i needed to specify my fields or if you could just input the form values.

 

The only info that isn't in the database now is the Dob.  In the database the Dob field shows the 0000-00-00 format, does this mean i make sure the potential users enter their Dob in that format ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.