Reputation: 780
I have two php files. one rules.php and one register.php
rules.php is like this:
<div style='background-color:#060; color:#FFF; width:50%; height:20px; font-size:12px; margin:5px 0;'>
<form method='post' action='register.php' name='form_coding_rules' id='form_coding_rules'>
<input type='checkbox' name='rules' id='rules' value='agree'/>
I Declare That I Read All The Above Rules & I Agree With Them.<br/><br/>
<input type='submit' name='terms' id='terms' value='Proceed'/>
</form>
</div>
</center>
And the register.php is as follows:
if( isset($_POST["terms"]) && isset($_POST["rules"]) && $_POST["rules"]=="agree" ) {
//Do Something;
}
else
header("location: rules.php");
But the problem is when I'm submitting from the rule page to register page then values not showing and the if part is skipping. After refresh or submitting 2-3 times if statement executing. But when I'm replacing the action page with a test page which just print the submitted values then everything fine. Didn't understand why its happening.
Upvotes: 0
Views: 136
Reputation: 213
Your last POST in your if statement is:
$_POST["rules"]="agree"
Should be
$_POST["rules"]=="agree"
Upvotes: 2