This question already has an answer here:
- The 3 different equals 8 answers
I am doing homework for a web development class where all I need to do is program a bunch of inputs in a form tag then send it to a php file to process and print it off in a results page. The problem I am having is in PHP printing out the sentences meant for values that I do not want it to deal with unless the condition of someone liking beer is true.
The following is my PHP code:
<?
$fullname=$_POST['fullname'];
$beer_like=$_POST['beer_like'];
$beer=$_POST['beer'];
$brand_cat=$_POST['brand_cat'];
$oktoberfest=$_POST['oktoberfest'];
print "You are $fullname, and you $beer_like beer. ";
if ($_POST['beer_like']="do like") {
print "You like $beer. ";
print "You listed $brand_cat as your beer brand preference. ";
print "Are you excited about Oktoberfest? $oktoberfest";
}
?>
The following is my HTML side:
<form action="homework3_results.php" method="post">
Please enter your first and last names: <input type="text" name="fullname"><br />
<h4> Do you like beer?</h4>
<input type="radio" name="beer_like" value="do like">Yes<br/>
<input type="radio" name="beer_like" value="are lame and do not like">No<br />
<h4> If you do not like beer, you do not have to continue. </h4> <br />
<h4> What types of beer do you like? </h4>
<input type="radio" name="beer" value="Lagers">Lagers <br />
<input type="radio" name="beer" value="Ales"> Ales <br />
<input type="radio" name="beer" value="both Ales and Lagers"> Both <br />
<h4> Choose a brand category from which you would buy </h4>
<select name="brand_cat">
<option value="American Macro">American Macro Brands(i.e. Budweiser)</option>
<option value="Microbrewers">Microbrewers</option>
<option value="Imports">Imports</option>
<option value="No preference">No Preference</option>
</select><br/>
<h4> Are you excited for Oktoberfest? Why or why not?</h4>
<input type="textarea" name="oktoberfest"><br />
<input type="submit" value="Submit Information">
</form>
Update, I tried moving the posts inside the if-statement, and it still does the same thing. I have no idea what to do.
Aucun commentaire:
Enregistrer un commentaire