PHP online Survey System source code-voting example

Source: Internet
Author: User
Tags php online

HTML code


The code is as follows Copy Code

<title> Survey Table </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" >

<?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 just a dork." > I'm just an idiot <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

The code is as follows Copy Code

<?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 are just like a smart person. ';
}

$favorite _second = count ($second);
if ($favorite _second <= 1)
{
$second _message = ' but you have done 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 ";
}
?>

<?php
if (empty ($stage)) {display_form ();}
else {process_form ();}
?>

</body>

Voting and in line investigation System example principle is to do a single or marquee, collect the user's information in the score.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.