Reputation: 137
PHP Code:
<?php
if (isset($_POST['pwsubmitted'])) {
$pwsub=$_POST['pass'];
if ($pwsub != "TEST"){
$s=1;
$msg = "Incorrect Password";
$msg2 = "Try Again";
}
else if ($pwsub == "TEST"){
$s=2;
$msg = "Password Accepted";
$msg2 = "Your Download Is Below";
$msg3 = "";
}
// so I can see what's going on when form submit happens
echo "s="; var_dump($s); echo "</br>";
echo "msg="; var_dump($msg); echo "</br>";
echo "msg2="; var_dump($msg2); echo "</br>";
echo "msg3="; var_dump($msg3); echo "</br>";
}
?>
Form, Placement Shown Below:
<div class="passform">
<form id="pwform" method="post" action="">
<input type="hidden" name="submitted" value="pwsubmitted" />
<center>
<span class="titleblue">Enter The Password</span>
</center>
<input name="pass" id="pass" type="password" class="password" />
<input name="submit" type="submit" class="submit" style="cursor: pointer;" value="" /></div>
</form>
</div>
Other Code:
<?php
if (isset($_POST['pwsubmitted'])) {
if ($s == 1) { Do This };
if ($s == 2) { Do This };
}
<?php if(!isset($POST['pwsubmitted'])) {
?>
<HTML FORM FROM ABOVE HERE>
<?php } ?>
When I submit the form... nothing happens. The original form stays up as if the pwsubmitted post variable isn't set. There's two different things that happen, either a msg saying try again, or it shows the content. Neither occur.
What did I do wrong??
Upvotes: 0
Views: 141
Reputation: 381
You should check for $_POST['submitted'] (name, not value of input).
Upvotes: 1
Reputation: 9299
In your HTML you have this input field
<input type="hidden" name="submitted" value="pwsubmitted" />
In your PHP you're using
if (isset($_POST['pwsubmitted'])) {
But the name of that field is submitted
. Try
if (isset($_POST['submitted'])) {
Upvotes: 6