Inserting data using mysqli

You should bind all variables once with bind_param() and not twice or N times. The correct way is pass first the types followed by the variables.

change:

$stmt2->bind_param('s',$username);
$stmt2->bind_param('s',$password);

By

$stmt2->bind_param('ss',$username, $password);

With php5.6 >= you can pass an array with ... operator to simplify.

$data = array('user' => 'someUser', 'password' => 'secret');
$stmt2->bind_param('ss', ...$data);

Leave a Comment