Reputation: 1009
I have a php form and I'm redirecting from:
http://wthdesign.net/contact.php
to this url:
http://wthdesign.net/contact.php?status=thanks
once my form is send:
but my problem is how do I prevent access to this url if the form was never sent in the first place?
Upvotes: 0
Views: 158
Reputation: 11602
Show us the source code off contact.php
indeed SESSION is proberly the best way to go, and set the session like this.
if (mail(...)) {
$_SESSION['allow_show_thanks'] = 1;
}
you have proberly some kind of switch case to handle status?
if (status == "thanks") {
} else {
// show form
}
change that to
if (status == "thanks" && (isset($_SESSION['allow_show_thanks'] && $_SESSION['allow_show_thanks'] == 1) ) {
// show thanks when status equals "thanks" AND SESSION['allow_show_thanks'] == 1
} else {
// show form
}
Upvotes: 1
Reputation: 5645
you just need to create session in the form and you need to check, whether the session was set with isset function. If not, use die at the beginning.
if (!isset($_SESSION['thank'])) die;
Upvotes: 2