Question

I'm sure this is me making some obvious mistake, but I'm very new to PHP/mySQL, and converting a simple user registration system to PDO for security. I've read through the docs and many threads, but still beating my head against a wall.

Simple HTML form posts an email address, php script is connecting fine to my database via PDO and I'm catching the email address here:

$email = $db->quote($_POST["email"]);

$query = $db->prepare("INSERT INTO userlogin (email) VALUES (:email)");

$query->bindParam(':email', $email, PDO::PARAM_STR);

$query->execute();

Expected database insert (or echo): name@email.com Actual database insert (or echo): 'name@email.com'

Seems like something so simple, but obviously I am missing a basic concept here. Appreciate any help.

Was it helpful?

Solution

Seems like something so simple,

yes. take out the first line and keep it this way:

$query = $db->prepare("INSERT INTO userlogin (email) VALUES (:email)");
$query->bindParam(':email', $email, PDO::PARAM_STR);
$query->execute();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top