У меня есть скрипт, который спрашивает, уверен ли я добавить новые данные.Мой php в порядке, потому что когда я хочу вставить данные с отключенным сценарием, он вставляется нормально.Но когда мой скрипт не отключен, он больше не вставляется ... Я не знаю, почему я не получаю никаких ошибок (вероятно, потому что есть 2 разных файла).
Мой сценарий
$(document).on("click", ".btnAddSubcat", function(e) {
event.preventDefault();
var subcatid = $('.CatEdit-select').val();
var subcatvalue = $('.subCat').val();
var subcatprocedure = $('.subProcedure').val();
var url = "../service/functions/postActions.php";
swal({
title: 'Add a new sub-category?',
text: "Are you sure to Add this sub-category?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, Add it!'
}).then(function () {
$.ajax({
type: 'POST',
url : url,
data: {
'cat-select': subcatid,
'subCat': subcatvalue,
'Procedure': subcatprocedure
},
success: function (data) {
swal({
title: 'Add!',
text: "You Add a sub-category!",
type: 'success',
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK'
}).then(function () {
window.location.reload();
})
}
});
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
если вам нужна моя функция вставки PHP или что-то еще, дайте мне знать
РЕДАКТИРОВАТЬ
Моя функция PHP
function AddSubCat() {
$Catid = $_POST['cat-select'];
$Subnaam = $_POST['subCat'];
$procedure = $_POST['Procedure'];
include '../../../include/dbConnection/dbcon.php';
//set update query ready for database, with info from the Ajax POST method for update.
$sqladdSubCat = 'INSERT INTO `*****`(`naam`,`Werkwijze`) VALUES ("'.$Subnaam.'","'.$procedure.'")';
//if query is done right then 'Record updated successfully'
if (mysqli_query($conn, $sqladdSubCat))
{
//get new colourId
$newUpload_id = mysqli_insert_id($conn);
//set update query hw_algoritmes thee cat id that may have change.
$sqlalgotime = 'INSERT INTO `*****`(`categorie_id`, `subcategorie_id`) VALUES ("'.$Catid.'","'.$newUpload_id.'")';
//if query is done right then 'Record updated successfully'
if (mysqli_query($conn, $sqlalgotime)) {
//check if there is a new front image add
if ($_FILES['HWVideo']['name'] == "") {
//Empty
} else {
uploadVideoHw($_FILES['HWVideo'], $newUpload_id);
}
} else {
echo "Error updating record: " . mysqli_error($conn);
}
header('Location: /cms/service/index.php');
} else {
echo "Error updating record: " . mysqli_error($conn);
// header('Location:../../Categorieen');
}
}