php - SQL - Data not being inserted, no error -
this question has answer here:
- how mysqli error in different environments? 1 answer
- reference - error mean in php? 29 answers
i have sql table table taking care of members list of website. however, when registering new user, data not inserted in table. no error being shown either check them few times throughout code.
if (empty($error_msg)) { // create hashed password using password_hash function. // function salts random salt , can verified // password_verify function. $password = password_hash($password, password_bcrypt); // insert new user database if ($insert_stmt = $mysqli->prepare("insert members (username, email, password) values (?, ?, ?)")) { $insert_stmt->bind_param('sss', $username, $email, $password); // execute prepared query. if (!$insert_stmt->execute()) { header('location: ./error.php?err=registration failure: insert'); } header('location: ./register_success.php?'); } }
the code executes end , redirected register_success. know it's not because have entered wrong data base credentials somewhere ele in code, sending data same database same credentials(they're kept in file) , works fine.
edit: after removing second "header" nick coons said, i'm getting redirected error page meaning there's problem execute. still, i've got no idea why...
you'll want use the documentation on page determine sql error is, if there one.
additionally, you're executing header()
function twice if there error, , second instance of overwrite first 1 (because can send 1 "location" header), redirect success page no matter what. recommend putting second header()
call in else
clause of if
statement, or adding exit()
after first call header()
1 or other executes.
Comments
Post a Comment