Today we are going to provide a PHP tutorial for the scholar of the online survey system of PHP Web tutorials, this is a simple example from HTML to PHP application, is about the online voting system code.
<?php Define display form functions function Display_form () {
Global $PHP _self;
?> <form action= "<?php echo $PHP _self?>" method=post> Name: <input type=text name= "name" ><BR> Single selection: <input Type=radio name= "A" value= "I'm stupid" > I'm smart. <input Type=radio name= "A" value= "I'm very stupid" > I'm stupid. <input type=radio name= "First" value= "I'm a fool" > I'm just a dork <br>
Multiple choices: <input type=checkbox name= "second[" value= "I like playing basketball" > I like playing basketball. <input type=checkbox name= "second[" value= "I like swimming" > I like swimming <input type=checkbox name= "second[" value= "I like dancing" > I like dancing. <input type=checkbox name= "second[" value= "I like mountain climbing" > I like hiking <input Type=hidden name= "stage" value= "Results" ><p> <input type=submit value= "Thank you" ></p> </FORM>
<?php } ?> Program start
<?php Defining processing form functions function Process_form () { Global $name; Global $first; Global $second;
if ($first = ' I'm stupid ') { $first _message = ' You're not stupid. '; } ElseIf ($first = ' I'm very smart ') { $first _message = ' You're not smart. '; } else { $first _message = ' You're like a smart man. '; }
$favorite _second = count ($second); if ($favorite _second <= 1) { $second _message = ' But you did wrong, repent! '; } ElseIf ($favorite _second > 1 && $favorite _second < 4) { $second _message = ' You are a sport-loving orangutan. '; } else { $second _message = ' You're exercising too much, and you're already overdoing it for chimps: ('; }
echo "This is a test:<br><br> for chimpanzees"; echo "Hello!" Your name is: $name. <br><br> "; echo "Your test results are ... $first _message $second _message "; } ?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.