madscientist
asked on
Cannot use PHP's if(isset()) if form submitted with Javascript
Hello all,
I have an HTML form which I'm processing with PHP, and I'm checking if the form has been submitted using if(isset($_POST['submit']) ), and if the form has not been submitted i throw up an error message and kill the script. My problem is that as well as using my normal submit button (<input type="submit" name="submit" id="submit" value="Submit Form" />) I would like to use a link with javascript to submit the form. I have my javascript as document.getElementById('f orm_name') .submit(); but if I use the javascript to submit the form, PHP responds with the error message. If I remove my if(isset($_POST['submit']) ) conditional, everything is fine, but ideally I would like this in place.
How do I solve this?
Many Thanks, Adam.
I have an HTML form which I'm processing with PHP, and I'm checking if the form has been submitted using if(isset($_POST['submit'])
How do I solve this?
Many Thanks, Adam.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
javascript: document.form1.submit();
The form should submit correctly. Make sure to replace form1 with the name of your form.
Hope this helps.