Not submitting to database but shows success message

Viewed 25
if ($stmt = $dbconn->prepare('INSERT INTO `astm_clients_tbl` (`u_name`, `u_email`, `u_password`, `u_plain_password`, `u_phone`, `u_referral_id`, `u_referrer`, `u_join_date`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) {
    $stmt->bind_param('ssssssss', $auth_name, $to, $password, $plainPass, $tel, $ref_id, $ref, $join_date);
    $stmt->execute();
    header('Location: register.php?msg=success');
    exit();
    $stmt->close();
} else {
    header('Location: register.php?msg=error');
    exit();
}
1 Answers

$stmt->execute() returns bool. Check if it's True before redirecting.

Take a cue below

if ($stmt = $dbconn->prepare('INSERT INTO `astm_clients_tbl` (`u_name`, `u_email`, `u_password`, `u_plain_password`, `u_phone`, `u_referral_id`, `u_referrer`, `u_join_date`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) {
    $stmt->bind_param('ssssssss', $auth_name, $to, $password, $plainPass, $tel, $ref_id, $ref, $join_date);
    if ($stmt->execute()) {
        header('Location: register.php?msg=success');
        exit();
        $stmt->close();
    }
} else {
    header('Location: register.php?msg=error');
    exit();
}
Related