`<?php
include_once "php/config.php";
$fname = mysqli_real_escape_string($conn, $_POST['fname']);
$lname = mysqli_real_escape_string($conn, $_POST['lname']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
if (!empty($fname) && !empty($lname) && !empty($email) && !empty($password)) {
// lets users email valid or not
if (filter_var($email,FILTER_VALIDATE_EMAIL)) {
}
else{
echo "$email + this is not a valid email";
}
}
else{
echo "All input fields are required";
}
?>const form = document.querySelector("#form");
const continueBtn = form.querySelector("#conBtn");
form.addEventListener("submit", (e) => {
e.preventDefault();//preventing form from submiting
});
continueBtn.addEventListener("click", () => {
// let's start Ajax
let xhr = new XMLHttpRequest();//creating xml object
xhr.open("POST", "php/signup.php", true);
xhr.onload = () => {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
let data = xhr.response;
console.log(data);
}
}
}
// we have to send the form data thourgh ajax to php
let formData = new FormData(form);//creating new formdata object
xhr.send(formData);//sending the form data to php
});`

Oldest comments (5)
Error 500 is a backend error. Check the PHP and apache error log.
check it but i dont know how to fix
You need to check the error message to discover what is bad in your code.
What is written there?
You should format your code in multiline:
```php
your code here```