I am new to pdo, and i wat to create a registration form all the code works including select qury but when i try to insert values to mysql I donot get any error but pdo insert do not insert any values in myaql table and always returns 0 rows insertd
`
<?php
function reg($err)
{
global $pdo_conn;
$fname = $err;
$tab = 'user_details';
$name = filter_var(strtoupper($_POST['name']), FILTER_SANITIZE_STRING);
$cc_code = filter_var($_POST['cc_code'], FILTER_SANITIZE_NUMBER_INT);
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$key = password_hash($_POST['key'], PASSWORD_DEFAULT);
$lvl = 1;
$date = date("Y-m-d");
$reg_chk_stmt = 'SELECT * FROM '.$tab. ' WHERE email = :email';
$reg_chk_qry = $pdo_conn->prepare($reg_chk_stmt);
$reg_chk_qry->bindParam(':email', $email);
$reg_chk_qry->execute();
$reg_chk_rows = $reg_chk_qry->rowCount();
if ($cc_code != $fname) {
$err_1 = 'Your firm is not autorized';
}else {
//$err_1 = 'your firm is authorized';
if ($reg_chk_rows != 0) {
$err_1 = 'email is alredy registerd';
}else{
try{
$reg_ins_stmt = "INSERT INTO " .$tab. " (name, email, pass, firm, lvl, created_on) VALUES (:name, :email, :pass, :firm, :lvl, :created_on)";
$reg_ins_qry = $pdo_conn->prepare($reg_ins_stmt);
$reg_ins_qry->bindValue(':name', $name, PDO::PARAM_STR);
$reg_ins_qry->bindValue(':email', $email, PDO::PARAM_STR);
$reg_ins_qry->bindValue(':pass', $key, PDO::PARAM_STR);
$reg_ins_qry->bindValue(':firm', $cc_code, PDO::PARAM_INT);
$reg_ins_qry->bindValue(':lvl', $lvl, PDO::PARAM_INT);
$reg_ins_qry->bindValue(':created_on', $created_on, PDO::PARAM_STR);
$reg_ins_echo = $reg_ins_qry;
$reg_ins_qry->execute();
}catch(PDOException $error){
$err_1 = $error->getMessage();
}
$reg_ins_rows = $reg_ins_qry->rowCount();
if ($reg_ins_rows != 0) {
$err_1 = $reg_ins_rows;
}else {
$err_1 = $reg_ins_rows . $reg_ins_qry;
}
}
}
$reg_chk_qry = NULL;
$reg_ins_qry = NULL;
return $err_1;
}
define('db_host','localhost');
define('db_user','dbuser');
define('db_pass','dbpass');
define('db_name','dbname');
// Establish database connection.
try
{
$pdo_conn = new PDO("mysql:host=".db_host.";dbname=".db_name,
db_user, db_pass,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
//echo "pdo connection works";
}
catch (PDOException $error)
{
exit("Error: could not connect to database");
}
$fname = 21828;
$error = reg($fname);
$header = 'Location: https://xyz.zy/index.php' . '?keyin_err=' . $error;
header($header);
?>
`
I tryed to run above code i donot get any error but my code donot insert any valuses to my mysql table