validating form input and then forwarding
Posted: Fri Sep 17, 2010 11:30 pm
Here's what Im looking to do and have had no luck getting it to work using my limited experience.
I have a form with 3 input text fields where the visitor would have to enter three 6 digit codes. They would find these codes on other pages on my website. once they have entered the codes correctly and clicked submit I would like them to be forwarded to the download page.
I have assigned the correct codes to variables $realcode1 $realcode2 and $realcode3 and then tried to compare them to the input data from the form.
Here's some code I wrote to attempt this.
I have no issue with the form,
form action="handle_form.php"
the contents of handle_form.php
I have been searching google and think i am mixing stuff together that is not needed. I would like it to be secure as well so any help with this would also be good.
Ideas or suggestions anyone?
I have a form with 3 input text fields where the visitor would have to enter three 6 digit codes. They would find these codes on other pages on my website. once they have entered the codes correctly and clicked submit I would like them to be forwarded to the download page.
I have assigned the correct codes to variables $realcode1 $realcode2 and $realcode3 and then tried to compare them to the input data from the form.
Here's some code I wrote to attempt this.
I have no issue with the form,
form action="handle_form.php"
the contents of handle_form.php
Code: Select all
<?php
$realcode1 = 723598;
$realcode2 = 193598;
$realcode3 = 887362;
$code1 = htmlspecialchars($_GET['code1']);
$code2 = htmlspecialchars($_GET['code2']);
$code3 = htmlspecialchars($_GET['code3']);
if ($code1 == $realcode1 && $code2 == $realcode2 && $code3 == $realcode3) {
header('Location: my download link')
} else {
echo "You haven't entered the correct codes.";
}
exit();
?>Ideas or suggestions anyone?