yes, i know there is already this kind of question, but i still don't get what i'm doing wrong...
Basically i'm doing a simple Ajax post in jquery to a PHP page, but the xhr status returns me HTTP 500
here the code:
function Register(mailval) {
var dataString = 'email1=' + mailval;
AJAX
// AJAX code to submit form.
$.ajax({
type: "POST",
url: "register.php",
data: dataString,
cache: false,
success: function(data) {
alert(data);
$(".modal-body").html('');
$(".modal-body").html(data);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
}
PHP
<?php
$email2 = $_POST['email1'];
$connection = mysqli_connect("127.0.0.1", "user", "psw");
$db = mysql_select_db("wnarshix_contatti_form", $connection);
if (isset($_POST['email1'])) {
$query = mysql_query("insert into user_registered(mail) values ('$email2')");
echo "Grazie per esserti registrato";
}
mysqli_close($connection);
?>
i'm not using mysqli properly?