Hi Friends,
This is the code of my current PHP project:
mainpage.php :
HTML Code:
<div><h1> Survey Questionnaire</h1></div>
<form id="form1" name="form1" method="post" action="process.php">
<label>Name:
</label>
<input type="text" name="name" id="name" />
</label>
<label>
Age:
<input type="text" name="age" id="age" />
Be prepared to answer some difficult questions!
How do you feel? </label>
<p>
<label>
<input type="radio" name="emotion" value="happy" id="happy" />
happy </label>
<label>
<input type="radio" name="emotion" value="sad" id="sad " />
sad
</label>
<label>
<input type="radio" name="emotion" value="angry" id="angry " />
angry
Why are you doing this survey?
<input type="radio" name="reason" value="there is nothing better to do" id="nothing" />
there's nothing better to do</label>
<label>
<input type="radio" name="reason" value="you have no life" id="life" />
you have no life</label>
<label>
<input type="radio" name="reason" value="you are being held against your will in an abandoned shack forced to answer these questions." id="held" />
you are being held against your will in an abandoned shack forced to answer these questions.</label>
</p>
<p>What is your favorite color?</p>
<p>
<label>
<input type="radio" name="color" value="red" id="red" />
red</label>
<label>
<input type="radio" name="color" value="yellow" id="yellow" />
yellow</label>
<label>
<input type="radio" name="color" value="green" id="green" />
green</label>
<label>
<input type="radio" name="color" value="blue" id="blue" />
blue</label>
<label>
<input type="radio" name="color" value="orange" id="orange" />
orange</label>
</p>
<p>
<label>What is your favorite season?
<input type="radio" name="season" value="autumn" id="autumn" />
autumn </label>
<label>
<input type="radio" name="season" value="spring" id="spring" />
spring</label>
<label>
<input type="radio" name="season" value="summer" id="summer" />
summer</label>
<label>
<input type="radio" name="season" value="winter" id="winter" />
winter</label>
<label>
What is your favorite genre of music?
<input type="radio" name="music" value="rock" id="rock" />
rock
</label>
<label>
<input type="radio" name="music" value="hip-hop" id="hip-hop" />
hip-hop </label>
<label>
<input type="radio" name="music" value="dance" id="dance" />
dance
</label>
<label>
<input type="radio" name="music" value="pop" id="pop" />
pop
</label>
<label>
<input type="radio" name="music" value="alternative" id="alternative" />
alternative
</label>
<label>
<input type="submit" name="button_1" id="button_1" value="Submit" />
</label>
</p>
</form>
process.php:
PHP Code:
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$emotion = $_POST['emotion'];
$reason = $_POST['reason'];
$color = $_POST['color'];
$season = $_POST['season'];
$music = $_POST['music'];
echo "<p>" . $name . ", you are " . $age . " years old." . "</p>";
echo "And you are " . $emotion;
echo "<p>" . $name . ", you are completing this survey because " . $reason . "</p>";
echo "Your favorite color is " . $color;
echo "<p>" . $name . ", your favorite season is " . $season . "</p>";
echo "You like " . $music . " music.";
?>
What would the if statement be if I wanted $color to change based upon the color? i.e if someone picked yellow as their favorite color how would I make the echoed $color text yellow?
Bookmarks