Php ajax

Please I need help on my project I’m using a mvc pattern to write my code and I want to validate the email input, I want to check if the email already exists in the database but my JavaScript is not seeing the php file

You are asking the wrong question. You do not check for an existing email. You set a unique constraint on the email field and then attempt the insert, capturing the duplicate error if any. Checking for an email will build in a race condition.

Please how do I do something like that using php ajax

You make a call with AJAX or Fetch to the file and return the result.

What is all your current code needed to reproduce the problem, less database connection credentials, and what symptom or error are you getting that leads you to believe that the Javascript is ‘not seeing the php file’?

I am working on a project using the PHP MVC pattern and I’m currently facing an issue with validating email input. My goal is to check if the email already exists in the database using JavaScript and AJAX. However, it seems that the JavaScript is not able to communicate with the PHP file designated for this validation.

I’ll guess you are calling the wrong file.

Sponsor our Newsletter | Privacy Policy | Terms of Service