AJAX values undefined with Symfony - javascript

I actually try to make an custom authentication using AJAX and Symfony but I have a problem that I can't even identify.
It seems that the AJAX part doesn't find the route because my browser console can't "recognize" my route script. I tried to identify AJAX data compared to input fields data and the problem is that AJAX returns undefined values. I'll put the different parts of my code below :
Twig modal with AJAX script :
<div class="modal fade" tabindex="-1" role="dialog" id="loginModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Connexion</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body" align="center">
<form action="#" method="POST">
<label for="pseudoMail">Pseudo ou e-mail : </label>
<input type="text" id="pseudoMail" placeholder="Pseudo ou e-mail" name="pseudoMail" required><br>
<label for="mdp">Mot de passe : </label>
<input type="password" id="mdp" placeholder="Mot de passe" name="mdp" required><br>
<input type="submit" class="btn btn-primary" id="login" value="Se connecter" />
</form>
</div>
</div>
</div>
</div>
<script src="{{ asset('js/jquery-3.5.1.min.js') }}"></script>
<script>
$(document).ready(function () {
$("#login").click(function()
{
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: 'POST',
url: '{{ path('checkLogin') }}',
data: {
pseudo: $("input#pseudoMail").val(),//TODO Remplir l'Ajax de façon à ce que les données soient reconnues
motdepasse: $("input#mdp").val()
},
dataType: 'json',
success: function(data)
{
if(data.pseudo !== "" && data.motdepasse !== "")//TODO Modifier la condition et jouer les sons correspondants (dossier sfx)
{
setTimeout(alert("Vous êtes connecté !"), 5000);
var sound = document.createElement('audio');
sound.setAttribute('src', 'https://themushroomkingdom.net/sounds/wav/smb/smb_1-up.wav');
sound.play();
}
else
{
alert("Les identifiants ne correspondent pas. Veuillez réessayer.");
var sound = document.createElement('audio');
sound.setAttribute('src', 'https://themushroomkingdom.net/sounds/wav/smb/smb_fireworks.wav');
sound.play();
}
},
error: function(data)
{
console.log("Pseudo : " + data.pseudo);
console.log("Mot de passe : " + data.motdepasse);
console.log("Pseudo sans data : " + $('input#pseudoMail').val());
console.log("Mot de passe sans data : " + $('input#mdp').val());
console.log(data);
alert("Erreur détectée ! " + data);
}
});
});
});
</script>
The PHP script :
/**
* #Route("/checkLogin", name="checkLogin")
*/
public function checkLogin(Request $request, SessionInterface $session)//TODO vérifier les connexions pour mesures de sécurité ?
{
$pseudoMail = $request->request->get('pseudoMail');
$motdepasse = $request->request->get('mdp');
$repo = $this->getDoctrine()->getRepository(Utilisateur::class);
$pseudoDB = $repo->findOneBy(["pseudo" => $pseudoMail]);
$mailDB = $repo->findOneBy(["email" => $pseudoMail]);
$motdepasseDB = $repo->findOneBy(["motDePasse" => $motdepasse]);
if (($pseudoDB && $motdepasseDB) || ($mailDB && $motdepasseDB))
{
$session->set('login', true);
/*return $this->render('boutique/index.html.twig', [
'controller_name' => 'BoutiqueController',
]);*/
var_dump($pseudoMail . "-" . $motdepasse);
return new JsonResponse(array('pseudo' => $pseudoMail, 'motDePasse' => $motdepasse));
}
else
{
$session->set('login', false);
//$this->addFlash('flash', "Login incorrect. Veuillez réessayer.");
/*return $this->render('accueil/index.html.twig', [
'controller_name' => 'AccueilController',
]);*/
return new Response("Problème !");
}
}

As charlietfl said, you get different keys between your AJAX code and your PHP code. They should equal.
data: {
pseudo: $("input#pseudoMail").val(),
motdepasse: $("input#mdp").val()
},
In your AJAX request, keys are pseudo and motdepasse. So, in your PHP code, you should use those keys like that:
$pseudoMail = $request->request->get('pseudo');
$motdepasse = $request->request->get('motdepasse');

Related

I am trying to upload video in laravel but not able to do so

Here is the Ajax part to add the video Url in the database.I am getting the value of Video title and video desc in database but not getting the url.
<div class="modal fade" id="addVideo" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-headerr">
<h5 class="modal-title" id="exampleModalLabel" data-toggle="modal">Add New Video</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-danger" style="display:none"></div>
<form class="image-upload" method="post" action="" enctype="multipart/form-data">
#csrf
<div class="form-group">
<label>Title</label>
<input type="tetx" name="addvideoTitle" id="AddvideoTitle" placeholder="Add a title"
class="form-control" />
</div>
<div class="form-group">
<label>Discription</label>
<input type="text" name="Addvideodesc" id="Addvideodesc" placeholder="Add a discription"
class="form-control" />
</div>
<div class="form-group">
<label>Add a video</label>
<input type="File" name="add-video" id="add-video" placeholder="Add a video to upload"
class="form-control" />
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" id="saveNewVideo">Save</button>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$(document).on('click','#saveNewVideo',function(){
var add_videotitle= $('#AddvideoTitle').val();
var add_videoDesc= $('#Addvideodesc').val();
var add_video= $('#add-video').val();
$.ajax({
type: "POST",
dataType: "json",
url: '{{ url('/event/saveEvent') }}',
data: {
'add_videoDesc': add_videoDesc,
'add_videotitle': add_videotitle,
'add_video':add_video,
_token: '{{csrf_token()}}'
},
success: function (data){
}
});
});
});
</script>
Controller code is written for adding video url in database I have written the value and getting the response but not actually saving the data in database.
public function saveEvent(request $request){
try{
if(!$request->ajax())
throw new \Exception('Not a valid Request');
$event =new Event();
$event->user_id=Auth::user()->id;
$event->event_name=$request->event_name;
$event->date=$request->event_date;
$event->time=$request->event_time;
$event->location=$request->event_location;
$event->cost=$request->event_cost;
$event->join_url=$request->event_join;
$event->add_video_title=$request->add_videotitle;
$event->add_video_desc=$request->add_videoDesc;
if($request->hasfile('add_video'))
{
$image = $request->file('add_video');
$extention= $image->getClientOriginalExtension();
$filename = time() . '.'. $extention;
$path = public_path('video');
$image->move('assets/video', $filename);
$imageurl=$path."/". $filename;
$event->video = $filename;
}
$event->save();
return response()->json(['status'=>true,'message'=>'Event Added Successfully','data'=>$event]);
}//end here try
catch(\Exception $e)
{
return response()->json(['status'=>false,'message'=>$e->getMessage()]);
}
}
According to Laravel Docs, in the case of Ajax calls - you could, for example, store the token in an HTML meta tag::
<meta name="csrf-token" content="{{ csrf_token() }}">
<script type="text/javascript">
// and then include in your ajax header like this:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$('#saveNewVideo').submit(function(e) {
e.preventDefault();
let formData = new FormData(this);
$.ajax({
type:'POST',
url: '{{ url('/event/saveEvent') }}',
data: formData,
contentType: false,
processData: false,
success: (response) => {
if (response) {
this.reset();
alert('Video has been uploaded successfully');
}
},
error: function(response){
$('#file-input-error').text(response.responseJSON.message);
}
});
});
</script>
That code is checking for the extension but not the MIME type. You should use the appropriate MIME type:
Video Type Extension MIME Type
Flash .flv video/x-flv
MPEG-4 .mp4 video/mp4
iPhone Index .m3u8 application/x-mpegURL
iPhone Segment .ts video/MP2T
3GP Mobile .3gp video/3gpp
QuickTime .mov video/quicktime
A/V Interleave .avi video/x-msvideo
Windows Media .wmv video/x-ms-wmv
If you are not sure about the MIME type of the file you are testing you can try $file->getMimeType()
public function store(Request $request)
{
$request->validate([
'video' => 'mimetypes:video/x-ms-asf,video/x-flv,video/mp4,application/x-mpegURL,video/MP2T,video/3gpp,video/quicktime,video/x-msvideo,video/x-ms-wmv,video/avi|max:204800'
]);
if($request->hasfile('add_video')) {
$unique_id = strtolower(str_replace('.', '', uniqid('', true)) . time());
$videoFile = $request->file('add_video');
$extension = $videoFile->getClientOriginalExtension();
$fileNameToStore = $unique_id . '.' . $extension;
$filepath = $videoFile->storeAs('video', $fileNameToStore);
$event->video = $filepath;
}
$event->save();
}
Store Files in Storage Folder
$file->storeAs('files', $fileName);
// storage/app/files/file.pdf
Store Files in Public Folder
$file->move(public_path('files'), $fileName);
// public/files/file.pdf
To display data on the front-end side.
$videoPath = !empty($pp_question->video) && Storage::exists($pp_question->video) ? Storage::url($pp_question->video) : asset(Storage::url('default/video.mp4');

My ajax query is repeated how many times I open my modal (Select Dynamic) [duplicate]

This question already has answers here:
why is jQuery click event firing multiple times
(5 answers)
Closed 11 months ago.
So, I have a project in laravel and now i'm working on the CRUD, specifically in the Update. Here I've a btn modal that show me the dates for edit and there I´ve a select dynamic.
The table with the btn:
#foreach ($mascotas as $mascota)
<tr>
<td class="text-center">{{$mascota->name}}</td>
<td class="text-center"> {{$mascota->especie}}</td>
<td class="text-center">{{$mascota->raza}}</td>
<td> <button class="btn btn-warning" data-bs-toggle="modal" data-bs-target="#modalEditCli"
onclick="modalEdit('{{$mascota->id}}', '{{$mascota->name}}', '{{$mascota->especie}}',
'{{$mascota->razaId}}', '{{$mascota->raza}}')"> <i class="fa fa-edit"></i> </button>
</td>
</tr>
#endforeach
#include('mascotas.modal_editar')
So, in the btn I'm calling the modal and the JS function at the same time.
The modal:
<div class="modal fade" id="modalEditCli" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form action="{{route('mascotas.store')}}" method="get" class="formularin"> #csrf
<div class="row">
<div class="col-4">
<div class="mb-3">
<label for="name" class="form-label"><b>Nombre Mascota:</b> <span class="text-secondary">*</span></label>
<input class="form-control" type="text" name="mascota_nm" id="mascota_nm" value="" required>
</div>
</div>
<div class="col-4">
<div class="mb-3">
<label for="especie" class="form-label"><b>Especie:</b> <span class="text-secondary">*</span></label>
<select class="form-control especie" name="especie" id="especie" required>
<option name="especie" value="0">Otro...</option>
<option name="especie" value="1">Perro</option>
<option name="especie" value="2">Gato</option>
</select>
</div>
</div>
<div class="col-4">
<div class="mb-3">
<label for="raza" class="form-label"><b>Raza:</b> <span class="text-secondary">*</span></label>
<select class="form-control raza" name="raza" id="raza" required>
<option value="0">Otro...</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-warning"> <i class="fa fa-edit"></i> Editar</button>
</form>
</div>
</div>
</div>
</div>
And here my JS function for the Select:
<script>
function modalEdit(id, name, especie, razaId, raza){
$('#id').val(id);
$('#mascota_nm').val(name);
$('.especie').val(especie);
$(".raza").prop('disabled', true); // Aplica el atributo "disabled" en el select.
$(".raza").html("<option value='"+ razaId +"'>"+ raza +"</option>"); // Limpia los datos del Select y solo deja la raza.
$(".especie").change(function(){
$(".raza").html("<option value='0'>Otro...</option>"); // Limpia los datos del Select y solo deja la opcion "Otro..."
var selectEspe = $('.especie').val();
$.post({
url: '/mascotas/dinamicQuery',
method: 'POST',
data: {
selectEspe,
_token: $('input[name="_token"]').val()
}
}).done(function(res){
$(".raza").prop('disabled', false); // Elimina el atributo "disabled"
var razas = JSON.parse(res); // Lee el archivo Json
$.each(razas, function(key, value){
var consulta = $(".raza").append('<option name="' + value.id + '">' + value.raza + '</option>');
});
});
});
}
</script>
And for last the Laravel query:
public function dinamicQuery(Request $request){
$especie = $request->selectEspe;
$razas = Especie::all()->where('especie', '=', $especie);
return response(json_encode($razas))->header('Content-type', 'text/plain');
}
So, the js query and the rest is working, if I open my modal it once the js query runs perfectly. But the problem is when I open any modal edit of the table for a second time o more. The "each" of my js query it runs as many times as modal is opened and I don´t know how why or how I can stop it.
Thanks for everything!
The problem is that every time when you click the edit <button/> it calls the modalEdit() function that attaches a new $(".especie").change() event.
Perhaps, the best solution is to move $(".especie").change() outside of the modalEdit() function. A quick workaround would be the .one()
Example:
<script>
function modalEdit(id, name, especie, razaId, raza){
$('#id').val(id);
$('#mascota_nm').val(name);
$('.especie').val(especie);
$(".raza").prop('disabled', true); // Aplica el atributo "disabled" en el select.
$(".raza").html("<option value='"+ razaId +"'>"+ raza +"</option>"); // Limpia los datos del Select y solo deja la raza.
}
$(".especie").change(function(){
$(".raza").html("<option value='0'>Otro...</option>"); // Limpia los datos del Select y solo deja la opcion "Otro..."
var selectEspe = $('.especie').val();
$.post({
url: '/mascotas/dinamicQuery',
method: 'POST',
data: {
selectEspe,
_token: $('input[name="_token"]').val()
}
}).done(function(res){
$(".raza").prop('disabled', false); // Elimina el atributo "disabled"
var razas = JSON.parse(res); // Lee el archivo Json
$.each(razas, function(key, value){
var consulta = $(".raza").append('<option name="' + value.id + '">' + value.raza + '</option>');
});
});
});
</script>

Javascript, Ajax : Bad Request 400

I'm working on ASP Net Core Project and I'm trying to send to my controller with JQuery Ajax function from a partial view modal, parameters.
The recovered URL is correct for example : http://localhost:44321/Validations/ValidationRefuse?ficheId=24&commentaire=Commentaire%20de%20test
But it's always :
Failed to load resource: the server responded with a status of 400 (Bad Request)
My Javascript :
$("#buttonRefusFiche").click(function (e) {
ficheId = $("#ficheId").val();
commentaire = $("#inputCommentaire").val();
$.ajax({
url: "/Validations/ValidationRefuse?ficheId=" + ficheId + "&commentaire" + commentaire,
type: 'POST',
contentType: 'application/html',
cache: true,
success: function () {
alert("Validation refusée.");
},
error: function () {
}
})
});
My C# method :
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ValidationRefuse(int ficheId, string commentaire)
{ ... }
My Partial View :
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Validez-vous cette fiche ?</h5>
<button type="button" class="btn btn-outline-dark btn-circle" data-dismiss="modal" aria-label="Close">
<i class="fa fa-close"></i>
</button>
</div>
<form asp-controller="Validations" asp-action="ValidationParResponsable" asp-route-id="#Model.FicheId" asp-route-eId="#Model.EnseignantId">
<div class="modal-body">
<div class="form-group">
<input type="hidden" id="ficheId" asp-for="FicheId" />
<input type="hidden" asp-for="EnseignantId" />
<input type="hidden" asp-for="EtatId" />
<label class="control-label font-weight-bold">Commentaire :</label>
<textarea class="form-control" id="inputCommentaire" asp-for="Commentaire" placeholder="Votre commentaire"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="buttonRefusFiche">Refuser</button>
<button type="submit" class="btn btn-success">Valider</button>
</div>
</form>
I hope it's understandable, thanks for your responses. :)
When you use a POST request you have to send the parameters in the body of the request, not in the URL like that :
$("#buttonRefusFiche").click(function (e) {
ficheId = $("#ficheId").val();
commentaire = $("#inputCommentaire").val();
$.ajax({
url: "/Validations/ValidationRefuse",
type: 'POST',
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
dataType : "html",
data : {
ficheId : ficheId,
commentaire : commentaire
},
cache: true,
success: function () {
alert("Validation refusée.");
},
error: function () {
}
})
});
I also changed the contentType and added dataType.
For more information about ajax Post see documentation

How to get a ID in a modal coming by dataTable?

My question is, I'm posting an ID into a modal, but when I click in a datepicker inside modal, it gives me as an undefined value, it seems that I'm losing the ID somewhere, could you help me? Here is my code:
Here is my modal HTML:
<div class="modal fade" id="modalUpdatePeriodico" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered " role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Prontuário médico</h4>
<!-- para pegar o id do meu campo -->
<input type="hidden" id="hiddenIdPeriodic"/>
</div>
<div class="modal-body">
<div class="row">
<!-- left column -->
<div class="col-md-12">
<!-- Inicio do Formulario de Pesquisa -->
<form id="formUpdatePeriodico" enctype="multipart/form-data" action="#" method="POST">
<!-- Form Data e Qtde dias -->
<div class="form-row">
<div class="form-group col-md-6">
<label for="dateExam">Data da Realização</label>
<input type="text" class="form-control datepicker-calendar" id="dateExam" name="dateExam">
</div>
<div class="form-group col-md-6">
<label for="statusExam">Status</label>
<select class="form-control select2" id="statusExam" name="statusExam">
<option value="1">Inapto</option>
<option value="2">Apto</option>
</select>
</div>
</div>
</form>
<!-- Fim do Formulario de Pesquisa -->
</div>
<!--/.col (right) -->
</div>
<!-- /.row -->
</div>
<div class="modal-footer">
<button
type="button"
id="btnSavePeriodic"
class="btn btn-success"
data-dismiss="modal"
onclick="saveEmpRestrictions('periodics', inputMatriculaAtes, dateExam, statusExam, hiddenIdPeriodic, examType);">
Salvar
</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Fechar</button>
</div>
</div>
</div>
Here is my DataTable JS code:
function tbPeriodic() {
// Definição do id da tabela como um dataTable
$("#tbPeriodico").DataTable({
"ajax": "webservices/ws_medicalRecord/tables/tb_medicalRecords.php?action=per&matriculaOp=" + <?php echo $matricula; ?>,
sorting: false,
"columns":
[
{ "data": "id" ,
render: function(data, type, row) { // Função para link de download dos arquivos que foram "upados" no formulário.
data = '' + row.id + '';
return data;
}
},
{ "data": "ult_exame" },
{ "data": "tipo_exame" },
{ "data": "status_exame" },
{ "data": "prox_exame" }
]
});
}
Here is my function to post my id into a input hidden:
$("#modalUpdatePeriodico").on('show.bs.modal', function (event) {
var callModal = $(event.relatedTarget); // Para pegar tudo que há na opção que chama o modal
var id = callModal.data('id'); // pegando o parametro ID da minha opção que chama o modal (data-id)
console.log(id);
var modal = $(this);
modal.find('.modal-header #hiddenIdPeriodic').val(id); // Adicionando o id em um campo hidden só para pegar esse valor depois
});
Here is my datepicker function:
$('.datepicker-calendar').datepicker({
autoclose: true
});
So, when I input a date from my datepicker the console shows me undefined, could you help me?
Thanks a lot!
I think you are confused here and there are 2 things happening. Or I should say there is one thing happening and the other step is missing. I am going to try and clarify this for you.
#1
The undefined is happening because you are not getting the value of id correctly. Add a class clickme to your dataTable <a> like below and get rid of the modal call.
dataTable
data = '<a class="clickme" href="#" data-id="' + row.id + '" id="' + row.id + '">' + row.id + '</a>';
Then get rid of
$("#modalUpdatePeriodico").on('show.bs.modal', function (event) {
var callModal = $(event.relatedTarget); // Para pegar tudo que há na opção que chama o modal
var id = callModal.data('id'); // pegando o parametro ID da minha opção que chama o modal (data-id)
console.log(id);
var modal = $(this);
modal.find('.modal-header #hiddenIdPeriodic').val(id); // Adicionando o id em um campo hidden só para pegar esse valor depois
});
and change it to
$(document).on('click', '.clickme', function() {
var id = $(this).data('id');
$('#modalUpdatePeriodico').modal('show');
$('#modalUpdatePeriodico').find('#hiddenIdPeriodic').val(id);
console.log(id);
})
#2
The date thing is a different event so add this to get the date
$('.datepicker-calendar').datepicker({
autoclose: true,
onSelect: function(date) {
console.log(date)
}
})

Modal dialog doesn't show up

I were changing some PHP-Script that you can't delete protected users from a datatable and now for some reason the modal which shows the warning "Are you sure to delete...?" doesn't show up anymore BUT the background gets dark and you can't interact with the page anymore (even if the selected user isn't protected)
I analyzed the code and haven't seen any issues (I am a amateur only knowing school IT)
HTML-Code
<div class="modal fade" tabindex="-1" role="dialog" id="modal_delete">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form method="post" ng-submit="submitForm()">
<div class="modal-header">
<h4 class="modal-title">{{modalTitle}}</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<h5>Sind Sie sich sicher diesen Benutzer unwiderruflich zu löschen?</h5>
<p ng-class="customStyle.colorClass">{{successMessage}}</p>
</div>
<div class="modal-footer">
<input type="hidden" name="hidden_id" value="{{hidden_id}}" />
<input type="submit" name="submit" id="submit" class="btn btn-info" value="Ja, ich bin mir sicher!"/>
<button type="button" class="btn btn-default" data-dismiss="modal">Schließen</button>
</div>
</form>
</div>
</div>
</div>
AngularJS (JavaScript) Code
$scope.openModalDelete = function(){
var modal_popup = $("#modal_delete");
modal_popup.modal('show');
$scope.deleteMessage();
}
$scope.closeModalDelete = function(){
var modal_popup = $('#modal_delete');
modal_popup.modal('hide');
}
$scope.submitForm = function(){
$http({
method: 'POST',
url: '../ajax/benutzer_insertData.php',
data: {
'isAdmin': $scope.isAdmin,
'password': $scope.password,
'passwordValidate': $scope.passwordValidate,
'id': $scope.currentId,
'first_name': $scope.first_name,
'last_name': $scope.last_name,
'email': $scope.email,
'action': $scope.submit_button}
}).then(function successCallback(response){
$scope.turnColor(response.data.color);
$scope.stateSet = $scope.state;
$scope.success = true;
$scope.error = false;
$scope.successMessage = response.data.successMsg;
$scope.errFirstName = response.data.firstNameError;
$scope.errLastName = response.data.lastNameError;
$scope.errEMail = response.data.eMailError;
$scope.errPassword = response.data.passwordError;
$scope.form_data = {};
$scope.getData();
});
}
$scope.deleteData = function(id){
$scope.modalTitle = "Benutzer löschen";
$scope.submit_button = "Löschen";
$scope.currentId = id;
$scope.openModalDelete();
}
PHP-Code
if($request->action == 'Löschen'){
$sql = "DELETE FROM users WHERE id = ".$id." AND protected = 0";
$statement = $con->prepare($sql);
$statement->execute();
$successMsg = "Benutzer wurde erfolgreich gelöscht";
$color = "green";
}
There are no things like Error-Messages and the console is completly fine

Categories

Resources