0

This function wont store the data to database:

function createJob($conn, $nameOfJob, $category, $jobDescripiton, $telephoneNumber){
$sql = "INSERT INTO jobs (jobName, category, description, phoneNumber, usersId) VALUES (?, ?, ?, ?, ?);";
$stmt = mysqli_stmt_init($conn);

if(!mysqli_stmt_prepare($stmt, $sql)){
    header("location:../job.php?error=stmtfailed");
    exit();
}
mysqli_stmt_bind_param($stmt, "sss", $nameOfJob, $category, $jobDescripiton, $telephoneNumber, $_SESSION["userid"]);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location:../job.php?error=none");
exit();

}

I have another function that checks if the fields are maybe empty, but the are not they are filled with data. I have another function to store user and it works:

function createUser($conn, $name, $email, $pwd){
$sql = "INSERT INTO users (usersName, usersEmail, usersPwd) VALUES (?, ?, ?);";
$stmt = mysqli_stmt_init($conn);

if(!mysqli_stmt_prepare($stmt, $sql)){
    header("location:../register.php?error=stmtfailed");
    exit();
}

$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);

mysqli_stmt_bind_param($stmt, "sss", $name, $email, $hashedPwd);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location:../register.php?error=none");
exit();

}

This is the database that is NOT working: enter image description here

This is the database that is working: enter image description here

0 Answers0