0
var_dump(array());

Will give you an empty array because that's what you passed to var_dumpty. I have no idea what you're doing but try this...

    $myarray = array(
        ":userName" => $userName,
        ":password" => $password,
        ":firstname" =>$firstname,
        ":Surname" => $Surname,
        ":gender" => $gender,
        ":dob" => $dob,
        ":email" => $email)
    );
    print_r($myarray);
    $stmt->execute($myarray);
0

Well it the array is not empty anymore.So why is that the data is not being inserted into the database?

0

Good question. Why? Have you made a mistake in the name of your table or your field names? Make an sql dump of your table and paste it here. The bit that starts "CREATE..."

Edited by diafol

0

And the other thing, there are certain information missing in the array

ITS WORKING!!Array ( [:userName] => [:password] => Pulavan123 [:firstname] => [:Surname] => [:gender] => M [:dob] => 23-10-1992 [:email] => )

Like username, firstname, second name and Email even though I have entered all the information before submitting the form

0

http://lumos.net63.net/Registration.html

<html>
<head>
<title> Registration </title>
</body>
<form name = "registration form" method = "post" action="Registration.php">
Username:<input type="text" name="name" value=""> </br>
Password:<input type="text" name="Password" value=""> </br>
First Name:<input type="text" name="First Name" value=""> </br>
Surname:<input type="text" name="Surname" value=""> </br>
Gender:<input type="text" name="Gender" value=""> </br>
DOB:<input type="text" name="DOB" value=""> </br>
Email Address:<input type="text" name="Email Address" value=""> </br>

<input type="submit" name="submit" value="submit">
</form>
</body>
</head>
</html>

and so why are the details not being entered into the database?

0

Change to these...

$userName = $_POST['name']; 
$firstname = $_POST['FirstName']; 
$Surname = $_POST['Surname'];
$email = $_POST['EmailAddress']; 
$password = $_POST['Password']; 
$gender = $_POST['Gender']; 
$dob = $_POST['DOB'];

Notice $Surname = $_POST['Surname']; use capitals for $_POST
Change your form to these...

Username:<input type="text" name="name" value=""> </br>

First Name:<input type="text" name="FirstName" value=""> </br>



Email Address:<input type="text" name="EmailAddress" value=""> </br>

Strip out all spaces in the names.

0

Okk...the information is being displayedd and one other thing..I have no idea why the details are not being inserted into the Databaseeeeee..I checked all the details such as the database name and its all correct.

0

OK, don't take this personally, but your record with spelling and naming so far hasn't been great, heh heh. So, how about sending the SQL dump for the CREATE TABLE... ?

0

hahha, I can spell properly but its not fun when you spell correctly. hahha. What do you mean by the SQL dump for the create table?

0

`

CREATE TABLE `User` (
 `username` varchar(20) COLLATE latin1_general_ci NOT NULL,
 `Password` varchar(10) COLLATE latin1_general_ci NOT NULL,
 `First Name` varchar(30) COLLATE latin1_general_ci NOT NULL,
 `Surname` varchar(30) COLLATE latin1_general_ci NOT NULL,
 `Gender` varchar(1) COLLATE latin1_general_ci NOT NULL,
 `DOB` datetime NOT NULL,
 `Email Address` varchar(50) COLLATE latin1_general_ci NOT NULL,
 PRIMARY KEY (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

Is this what you are asking for?

0

["DOB"]=> string(10) "23-10-1992"

This format is not compatible with datetime type, the format should be

Y-m-d H:i:s (the time part is optional and should default to 00:00:00)

0

Its not making a difference Array ( [:userName] => mfredy [:password] => Pulavan123 [:firstname] => Fareedh [:Surname] => [:gender] => M [:dob] => 1992-10-23 [:email] => fareedh92@hotmail.co.uk )

1

INSERT INTO User (username,Password,`First Name`,Surname, Gender, DOB, `Email Address`) VALUES ('mfredy','Pulavan123','Fareedh','', 'M', '1992-10-23', 'fareedh92@hotmail.co.uk')

Paste that straight into phpmyadmin SQL box. See if a record is added.
Note that surname is still not added - did you change $_Post to $_POST ?

Edited by diafol

0

I have changed that and this sis the error I am getting

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name,Surname, Gender, DOB, Email Address VALUES ('mfredy','Pulavan123','Fareedh'' at line 1

0

Sorry try it now. The editor stripped out the backticks - I've edited the SQL, so try copy/paste again.

0

IT WORKEDDD.

SO should I copy that sql code and paste into the php?

Sorry for the late reply. I went to sleep cos I was so tired hahah

Edited by Mohamed_26

0

Someone asked me to try to this code and I got an error code called errorcode = 3D000 and when I earched it up it said it means No Database Selected or something like that.

<?Php

include 'connect.php';


    $userName = $_POST['name']; 
    $firstname = $_POST['FirstName']; 
    $Surname = $_POST['Surname'];
    $email = $_POST['EmailAddress']; 
    $password = $_POST['Password']; 
    $gender = $_POST['Gender']; 
    $dob = $_POST['DOB'];


    $query = 'INSERT INTO User (username,Password,`First Name`,Surname, Gender, DOB, `Email Address``username`,`Password`,`First Name`,`Surname`, `Gender`, `DOB`, `Email Address`) 
                VALUES (:userName, :password, :firstname, :Surname, :gender, :dob, :email)';


    try {
    $stmt = $conn->prepare($query);
    $result = $stmt->execute (array(
        ":userName" => $userName,
        ":password" => $password,
        ":firstname" =>$firstname,
        ":Surname" => $Surname,
        ":gender" => $gender,
        ":dob" => $dob,
        ":email" => $email));
    print_r($myarray);
    if ($result) {
       // success!
       echo 'lastInsertId = '.$conn->lastInsertId(); 

    } else {
       // Query failed.
       echo 'errorcode = '.$stmt  ->errorCode();
    }
} catch(PDOException $err) {
    echo "Houston we have a problem: $err";

    }

?>
0

Oh Crappp!! I forgot to do that. I have done that. Now, I am getting an error code =23000

0

I HAVE SORTEDD ALL THE ERRORS OUTT!!! IT WORRKSSSSSSSSSSSSSSSSSSSS. THANK YOU SOOO MUCHH...I GUESS ITS MY STUPIDITY THAT CAUSED A LOT OF ERRORS..GUESS I HAVE LEARNED A LOT..THANK YOU AGAIN!!

I will probably come back for more help a bit later..Thank youuu AGAIN!!!

0

I will probably come back for more help a bit later..

Give me a couple of days to get over it first, lol.

0

hahhaa.. you are funny. I wish you were my tutorrrrr. You would be really awesome and sure I will hahha.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.