Reputation: 51
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
Upvotes: 0
Views: 191
Reputation: 10041
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.
Upvotes: 1