I have been trying to solve an annoying behavior with PHP (I think..). Maybe some of you have encountered the same and have some ideas. I have an html form and I use an element with the onClick event that calls a javascript function. Once the script's content has been processed, I execute the form.submit() directive. It basically checks common things like length of fields, etc.
Now my problem is, when I use input type button, I set its name to submit1, and just to run a small test, I set the <form id="register" action="<?php echo($PHP_SELF) ?>" method="post">
I then put:
<?php
if (isset($_POST["submit1"])) {
echo "Submit button was pressed";
die();
}
?>
However, I never see the message even though my input button's name is submit1. I then changed the input type to submit, and I click submit, I'll see the message but the only problem is that even if my javascript function finds any errors in the form, after clicking okay on the alert box, the form continues regardless. It only does this on submit type=submit.
If anyone is interested,
my buttons: 1st try:
<input type="button" name="submit1" class="submit" value="Register"
onclick="validateFields()" />
2nd try:
<input type="submit" name="submit1" class="submit" value="Create Account!"
onclick="validateFields()" />