I am not a PHP expert. I have a form that has Captcha validation image. the form has a button "submit", and the code for the submit is within the same page (let's call it "code 1"):
<form method="post" name="emailForm" action="email.php">
Name:<input type="text" name="name"><br>
Email Add:<input type="text" name="email"><br>
Message:<textarea rows="10" cols="40" name="message">/textarea><br>
<input name="SubmitCF" type="submit" value="Send Email" class="button1"><br>
</form>
As I understand, the php concept is that the button action code in done by the following code fragment, and not by loading the file stated in the form's "action" tag, which is the php file "email.php" (in the form's declaration above) as in the following code fragment (let's call it "code 2"):
<?php
if (isset($_POST['SubmitCF'])) {
// Validate Captcha code ...
}
}
?>
The problem I face is as follows: when I have the "action="email.php" " in the form declaration, then the "email.php" is run but not the validation captcha code in "code 2", therefore the Captcha code is not validated (which is a bug). but when I delete the "action="email.php" from the form's declaration, then "code 2" is executed, and the "email.php" is not loaded and executed, and is it also a bug.
What is the way to validate the Captcha code, and only after the Captcha is validated, make the "email.php" in the form;s "action" declaration load and run?
how to run the "submit" button code within the same page, and only upon confirmation, load and execute the php file which is in the form's action declaration.
Many thanks to the answering members for their help and time.