I have a situation where a user fills out 1 of 2 forms on a registration page and is sent to a software download page. If they sign up as a new user, form is processed inserted into a MySQL database and they go to the page no problem.
Here is my issue. If they are a returning user and enter a license key, the processor script checks to see if its valid against the database and if it is it sends them to the software download page. If it is NOT a valid license key (heres what I dont like) the screen goes to the url of the script, page is white, an alert pops down telling them its not a valid license key and they are returned to the registration page to try again. I hate this. I need to figure out a way to either pop the alert on the registration page w/o leaving it or better yet display some kind of message on the page. One drawback is that the script is and always will be on a different server than my forms. Ive tried curl and had success with other situations but can’t close the MySQL connection on this one. Is there another way to achieve some semblance of “cross domain AJAX” I would really like it to not go to the script url/white page/alert then return them. I would like it to happen all on one page. Here is that part of my script:
Is it possible to remove the alert and when you redirect to registrationpage.php also send a parameter using the redirect url and popup an alert or error message after the redirect ?
Look into using AJAX. jQuery has a great API for this:
EDITIED – For cross-domain
You could do something like this:
This will (once the IDs are pointed at the correct elements) intercept the form submission, pull together the values from the form (through the
serialize() function), and shoot it out to the validation script via AJAX. The output of the script is displayed in the
Hope this helps!