I'm planning to make a chat function using AJAX, javascript, and HTML and I figured I would use AJAX to send the form (text) to the server and store it in a text file that can be sent to other people using my chat function through AJAX so the page doesn't have to refresh. But now I'm starting to get worried about security because even though I know how to validate my form through javascript, people can disable it. Is there any way I can get PHP to validate my form before it is sent through AJAX to the server without refreshing the page? And yes, I know I could just download someone elses chat function, but wheres the fun in that? lol ~imozeb
Send the POST request using AJAX to a php validation script. Now that script can send the result of validation back to the browser.
Okay, is this right? Submit part: (User submits form, sends to javascript file for validation, sends to PHP file for validation, saves in .txt file) Output part: (Uses AJAX to get .txt info and outputs to page using <div> tags) And if I'm understanding correct, if a different PHP file (not the current page) submits the form the current page doesn't have to be refreshed?
this is how will it go(to avoid page refresh): Submit part: (User submits form, sends to javascript file for validation, use AJAX to transport data to PHP file,PHP file validates, saves in .txt file) Output part: (Uses AJAX to get .txt info and outputs to page using <div> tags) Even if the post is in the current page or on other page,the page will still refresh if you haven't used AJAX for it.