您好,我尝试将值插入由服务器(gandi)托管的数据库(在phpmyadmin中),但出现此错误,我不知道如何解决它 我的错误:
jquery.min.js:4 POST
http://95.... 500 (Internal Server Error)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
(anonymous) @ (index):65
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
triggerMouseEvent @ ionic.bundle.js:2953
tapClick @ ionic.bundle.js:2942
tapMouseUp @ ionic.bundle.js:3018
我的代码:
app.controller('ajoutUtilisateurCtrl', function($scope)
{
$('#submit').click(function(){
var nom = $scope.nom;
var prenom = $scope.prenom;
var email = $scope.email;
var advertisement = $('#nom').val() + $('#prenom').val() + $('#email').val();
var datastring = {nom: nom, prenom: prenom, email: email};
if(advertisement=='')
{
$('#response').html('Veuillez saisir les données');
}
else{
$.ajax({
type: "POST",
url: "http://95.../ajoutUtilisateur.php",
data: datastring,
cache: false,
success: function(result){
$('#response').html(result);
var advertisement = $('#nom').val("") + $('#prenom').val("") + $('#email').val("");
}
});
return false;
}
})
});
ajoutUtilisateur.php
<?php
include_once('config.php');
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$email = $_POST['email'];
$sql = "INSERT INTO utilisateur(nom, prenom, email) VALUES('$nom', '$prenom', '$email')";
if($connexion->query($sql) === TRUE){
echo 'Utilisateur ajouté';
}
else
{
echo 'Erreur ajout utilisateur';
}
?>
config.php
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', 'db');
define('DB_USERNAME', 'user');
define('DB_PASSWORD', '');
$connexion = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME) or die("Could not connect to database");
if(mysqli_connect_errno()){
echo('Connexion non établie'.mysqli_connect_error());
exit();
}
?>
如何解决此问题?