php - SQL - Data not being inserted, no error -


this question has answer here:

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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -