PHP online poll System Source code example

Source: Internet
Author: User
Keywords Web Programming PHP Tutorials
Tags application checkbox code content echo example html html code

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.

HTML code


<html>
<head>
<title> Questionnaire </title>
<meta http-equiv= "Content-type" content= html; charset=gb2312 ">
</head>
<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 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 ";
}
?>

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

Polling and online survey System example principle is to do a single or marquee, collect the user's information in the score.

Related Article

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.