I have some issues with PDO. my app run smoothly in xamp but when i host it, i cannot insert data into the database
this is the jquery code
$(document).ready(function() {
$('form.ajaxform').on('submit', function() {
var that = $(this);
url = that.attr('action');
type = that.attr('method');
data = {};
that.find('[name]').each(function(index, value){
var that = $(this);
name = that.attr('name');
value = that.val();
data[name] = value;
});
$.ajax({
url: url,
type: type,
data: data,
success: function(response){
$('#feedback').html(response);
}
});
this is the php code
require_once 'functions.php';
if(!loggedIn()) {
header('location: ./');
}
if(isset($_POST['submit'])) {
$agent = $_POST['agent'];
$agentphone = $_POST['agentphone'];
$passport = $_POST['passport'];
$surname = $_POST['surname'];
$gnames = $_POST['gnames'];
$nationality = $_POST['nationality'];
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$pobirth = $_POST['pobirth'];
$poissue = $_POST['poissue'];
$isdate = $_POST['isdate'];
$exdate = $_POST['exdate'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$group = $_POST['group'];
$dependent = $_POST['dependent'];
$drelation = $_POST['drelation'];
$dphone = $_POST['dphone'];
$regBy = $staff->name;
$branch = $staff->branch;
$checkClient = $db->getRow("SELECT * FROM clients WHERE passportNumber = ?", [$passport]);
if($checkClient) {
echo "
<div class=' col-md-10 float-left'>
<div class='alert alert-danger rounded-0'>
<strong><h5>Error!!! Client Already Exist</h5></strong>
</div>
</div>
";
} else {
$regClient = $db->insertRow("INSERT INTO clients(agent, agentPhone, passportNumber, dateofIssue, expiryDate, placeofissue, placeofbirth, nationality, surname, givename, dobirth, gender, phone, clientGroup, email, dependentName, relationship, dphone, registeredBy, branch)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
[$agent, $agentphone, $passport, $isdate, $exdate, $poissue, $pobirth, $nationality, $surname, $gnames, $dob, $gender, $phone, $group, $email, $dependent, $drelation, $dphone, $regBy, $branch]);
if($regClient) {
echo "
<div class=' col-md-10 float-left'>
<div class='alert alert-success rounded-0'>
<strong><h5>Successfully Registered</h5></strong>
</div>
</div>
<div><meta HTTP-EQUIV='Refresh' CONTENT='2; URL=dashboard'></div>
";
}
}
}