hey guys, so i have a contact form which is validated with a captcha system i have made, here is the code:
<?php
// code for captcha
session_start();
// this is starting the session made in generate.php and making it so the numbers generated are between
// 1000-9999
// we do a if statement so that it links to the submit button and if entered incorrectly it outputs
// and refreshes the image to a new one.
if (!isset($_POST['secure']) ){
$_SESSION['secure']=rand(1000,9999);
}else{
if ($_SESSION['secure'] == $_POST['secure']){
}else{
echo"incorrect captcha code";
$_SESSION['secure']=rand(1000,9999);
}
}
?>
<div class="contactform">
<h1 class="buslistheader">Send an e-mail</h1>
<form id="form1" name="form1" method="post" action="contact_us.php">
<table class="center" cellspacing=0 cellpadding=0>
<tr>
<td class="inputlabel"><label for="Name" >* Name:</label></td></tr>
<tr><td><input class="inputbox" type="text" name="name" id="Name" maxlength="30" required></td>
</tr>
<tr>
<td class="inputlabel"><label for="companyName">Company Name:</label></td><tr>
<tr><td><input class="inputbox" type="text" name="companyname" id="companyName" maxlength="30"></td>
</tr>
<tr>
<td class="inputlabel"><label for="email">* Email:</label></td></tr>
<tr><td><input class="inputbox" type="text" name="email" id="email" maxlength="50" required></td>
</tr>
<tr>
<td class="inputlabel"><label for="subject"> Subject:</label></td></tr>
<tr><td><input class="inputbox" type="text" name="subject" id="subject" maxlength="40" required></td>
</tr>
<tr>
<td class="inputlabel"><label for="message">* Message:</label></td></tr>
<tr><td><textarea class="inputarea" name="message" id="message" maxlength="2000" required></textarea></td>
</tr>
<tr>
<td><img src="generate.php" class="captchabox" /></td>
</tr>
<tr>
<td><input class="inputbox" type="text" name="secure" style="border-top:2px solid #54792D;"></td>
</tr>
<tr>
<td><input class="submitbutton" type="submit" value="Send An Email"></td>
</tr>
</table>
</form>
</div>
now when i enter the correct captcha, all goes well, and when i enter the wrong captcha, again all goes well as it outputs a message saying the captcha code is wrong. this is because the form action is set to the current page. but when i put the actualy redirect action to "sent.php", no matter if i put the correct/wrong captcha code, it still redirects me to the page "sent.php" . how do i make it so it only redirects to that page IF the captcha code is correct.
thanks alot.