#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    17
    Rep Power
    0

    Ii have a problem with this registration script can some please help


    session_start

    `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <?php
    if(isset($_POST["Email"]) && isset($_POST["Password"])){
    $name=$_POST['First_name'];
    try {$pdo_options[PDO::ATTR_ERRMODE]=PDO::ERRMODE_EXCEPTION ;
    $Dbc= new PDO('mysql:host=localhost;dbname=abakwa','admin','anthony',$pdo_options);
    //$register=$Dbc-> exec("INSERT INTO user(first_name,last_name,email,Date_of_birth ,password)VALUES(" .$_POST['First_name'],$_POS
    //T['Last_name'],$_POST['Email'],$_POST['Date_of_birth'],$_POST['Password']);
    $Register_user=$Dbc->prepare("INSERT INTO user(First_name,last_name,Email,Date_of_birth ,password)VALUES(:First_name,:last_name,:Email,ate_of_birh,assword)");
    $Register_user->execute(array(
    'First_name' => $name,
    'Last_name'=>$_POST['Last_name'],
    'Email'=> $_POST['Email'],
    'Date_of_birth'=>$_POST['Date_of_birth'],
    'password' => $_POST['Date_of_birth']) );
    // echo "Your Detials have been added to the data base";
    //get user_name which has that acc
    }
    catch(Exception $e)
    {die ('ERROR: '.$e->getMessage());
    }
    }
    ?>
    <form method="post" action="register.php ">
    First Name:
    <input type="text" name="First_name" /><br />

    Last Name:
    <input type="text" name="Last_name" />
    <br />
    Email:
    <input type="text" name="Email" />
    <br />
    <input type="text" name="Date_of_birth" />

    Password:
    <input type="Password " name="Password" /><br />
    <br />

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


    ERROR: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,465
    Rep Power
    594
    1) Please edit your post and enclose your code in [ PHP ] tags. See the sticky at the top of the forum and ManiacDan's New User Guide. Also use proper indentation on your code.
    2) Your insert is messed up. The VALUES are all strings not enclosed in quotes.

    Comments on this post

    • simplypixie agrees
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    17
    Rep Power
    0
    plz could u be more explicit i do not understand
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    the parameter names don't match: In the prepared statement, you use "last_name" with a lowercase "l", but in the parameters you use "Last_name" with an uppercase "L".

    Which is why mixed case is a bad idea in the beginning -- even though people really seem to love it. Names are supposed to be unambiguous, not pretty.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,465
    Rep Power
    594
    PHP Code:
    $Register_user=$Dbc->prepare("INSERT INTO user(First_name,last_name,Email,Date_of_birth ,password)VALUES('First_name','last_name','Email','Date_of_birth','Password')"); 

    Comments on this post

    • Jacques1 disagrees : No, his syntax is correct. He's using prepared statements in PDO. He certainly doesn't want to insert the literal strings 'First_name', 'last_name' etc.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo