DEV Community

Cover image for Can anyone help me why this error are show?
ARIF
ARIF

Posted on

Can anyone help me why this error are show?

`<?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";
}
Enter fullscreen mode Exit fullscreen mode

?>
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
});`

Image description``

Top comments (5)

Collapse
 
lexlohr profile image
Alex Lohr •

You should format your code in multiline:

```php
your code here
```

Collapse
 
lito profile image
Lito •

Error 500 is a backend error. Check the PHP and apache error log.

Collapse
 
arif0ne profile image
ARIF •

check it but i dont know how to fix

Collapse
 
lito profile image
Lito •

You need to check the error message to discover what is bad in your code.

Collapse
 
baloraki profile image
baloraki •

What is written there?