0

Hi this is the first time I've written php to process form data, I have already implemented the jQuery to validate, and I have written the PHP to process the form, and also encryption, salting escaping and filtering, before I write the code to insert the data into the db, I am just wondering how to send the results of the php validation back to the front end. There is a level of security in the jQuery, however this might be turned off, but the level of security through the php is greater, especially regarding email validation. The PHP is in a seperate file, so I'm wondering the best way to connect the PHP programs back to the front end to inform the user as to whether their data is acceptable. I've heard of session redirects, and also Ajax but would not want to use this in case JS is turned off.

Thanks Ant

2
  • Can you show us some code here? Are you using a framework? Your JavaScript/Ajax should not interfere with PHP handling on the server side if you have things set up properly. You're going to need to send POST vars back to the user if they've failed your server side validation. Are you checking that the form is posted in PHP? Commented Oct 2, 2012 at 22:20
  • Make sure every validator/filter is used on the PHP side as well. Commented Oct 2, 2012 at 22:34

1 Answer 1

1

Use AJAX for that, that will allow you to send the data to your PHP script, and keep the user on the current page. You can then return something like true or false depending if everything passed PHP's validation.

If a user has Javascript disabled, then they don't get to have fancy websites doing fun and interesting things. Take a look here for how to handle if a user does not have javascript enabled.

Essentially, you will need to do a regular form and have the user submit/reload the page with whatever error/success message(s) needed for them to know they are done or fix their errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.