Not sure whats going on, this is my first time ever using prepared statements, trying to harden my source code. Getting an internal 500 error when calling the save.php file via ajax. Can anyone gut check my code and tell me if there are errors? No errors come out of the code except for a 500 error in the console, PHP INI errors are empty and no MYSQLI errors either.
Note: I have already enabled logging and errors and both return empty
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(E_ALL);
include '../../admin/app/config.php';
if(count($_POST)>0){
if($_POST['type']==1){
$sql = "INSERT INTO `users`(`client_id`,`first_name`,`last_name`,`email`,`role`)
VALUES (?,?,?,?,?)";
if ($stmt = mysqli_prepare($link, $sql)) {
$client_id=$_POST['client_id'];
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$email=$_POST['email'];
$role=$_POST['role'];
mysqli_stmt_bind_param($stmt, "sssss", $client_id,$first_name,$last_name,$email,$role);
mysqli_stmt_execute($stmt);
echo json_encode(array("statusCode"=>200));
}
else {
mysqli_error($link);
}
// Close statement
mysqli_stmt_close($stmt);
// Close connection
mysqli_close($link);
}
}
Just looking for a nudge in the right direction or if I am missing something like perhaps I need to enable prepared statements in PHP.INI? Not sure, again first time with prepared statements. save.php is permissioned and chmod'd correctly, works fine in normal non prepared statement mode which makes me think its a server issue but not sure where to start looking there.