PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Basically I have these two divs, one is the default but if the person enters the correct discount it should be hidden and the other one displayed, if they enter the wrong code it should leave the default and display "wrong code" I know this is not secure, but it is not important for this. Obviously, I am not a coder .
<?php
// Set discount to true or false
if($_POST['txtdiscount'] == 'rain15'){
$discount = true;
}else{
$discount = false;
}
// show form if not submitted
if($_SERVER['REQUEST_METHOD'] != 'POST'){ ?>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtdiscount" style="color:red">Discount Code:</label>
<input type="discount" title="Enter Discount Code" name="txtdiscount" />
</p>
</form>
<div id="div1">Content to show before submit</div>
<?php }else{ // if submitted, show result ?>
<?php if($discount){ // if discount, show correct text ?>
<div id="div2">Content to show if discount is correct</div>
<?php }else{ // if not discount, shot incorrect text ?>
<div id="div3">Content to show if discount is incorrect</div>
<?php } // end discount if ?>
<?php } // end post if ?>