I have problem in PHP. Insert is not working and I don't know why!
public function create($table,$fields =array()){
$columns=implode(' ', array_keys($fields));
$values=':'.implode(', :',array_keys($fields));
$sql="INSERT INTO {$table} ({$columns}) VALUES ({$values}))";
var_dump($fields);
if($stmt =$this ->pdo ->prepare($sql)){
foreach ($fields as $key => $data) {
$stmt ->bindValue(':' .$key,$data);
}
$stmt ->execute();
return $this->pdo->lastInsertId();
}
}
And the signup form is this:
$user_id=$getFromU->create('users', array(email => $email,'password' =>md5($password),'screenName' => $screenName, 'profileImage' =>'assets/images/defaultProfileImages','profileCover' =>'asset/images/defaultCoverImages'));
$_SESSION['user_id']=$user_id;
header('Location:includes/signup.php?step=1');