HTML form when submitted via PHP to MySQL sending blank values -



HTML form when submitted via PHP to MySQL sending blank values -

so variables set.

my connection working.

but i'm still getting blank values sent db.

$stmt = $connection->prepare('insert emails (email, first, last) values (?,?,?)'); $stmt->bind_param('sss',$email, $first, $last); $email = mysql_real_escape_string($from); $first = mysql_real_escape_string($fname); $last = mysql_real_escape_string($lname); $stmt -> bind_result($result); $stmt->execute();

i'm not prepared statements, it's exclusively possible it's wrong, if share insight great.

(edit: variables said values)

i don't see why you're escaping strings after binded them query. pointed out, don't need them when using prepared statements.

if(!$stmt = $connection->prepare("insert emails (email, first, last) values (?,?,?)")) { die($connection->error); } $stmt->bind_param('sss', $from, $fname, $lname); $stmt->execute(); $stmt->close();

this should input values or display error. farther debugging, echo $from, $fname, $lname variables ensure think are.

edit

and else pointed out (but missed since didn't pay attending title of question), we're working under assumption $from, $fname , $lname defined @ all. if submitted through form, can defined using

$from = $_post["from"]; $fname = $_post["fname"]; $lname = $_post["lname"];

replace names within of $_post[" "] whatever name these fields in html form. , maintain in mind needs done before register them bind_param

php html mysql database forms

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -