Posted by: tonyteaching | February 18, 2009

to create SURVEY FORM

I want to create an online survey form like this:

survey1

How to make it?

————————————————————–

To make it we need 2 files and 1 Table in a database:

– Form interface (html file), for example: “surveyform.html”

– Program for processing the input data (PHP file), for example: “insert.php”

– 1 Table in a database (MySQL), for example: database “smsegov” with table “survey1”

Let’s create it!

—————————-

1. Creating Form interface: “surveyform.html”

<HTML>

<HEAD>

</HEAD>

<BODY>

<form action=”insert.php” method=”POST” >

<center> <H2> Citizens’ Motivation to USE or NOT TO USE an SMS service for public services </H2> </center>

<H3> <i>Part A. Demographics </i> </H3> </td>

<table>

<tr>

<td> <font face=”arial” size=”4″> 1. Sex:</td>

<td><font face=”arial” size=”4″> <input type=”radio” name=”sex” value=”M”> Male

<input type=”radio” name=”sex” value=”F”> Female </td>

</tr>

<tr>

<td><font face=”arial” size=”4″> 2. Ages (years old):</td>

<td><font face=”arial” size=”4″> <input type=”radio” name=”ages” value=”1″> 18-20

<input type=”radio” name=”ages” value=”2″> 21-25

<input type=”radio” name=”ages” value=”3″> 26-30

<input type=”radio” name=”ages” value=”4″> 31-40

<input type=”radio” name=”ages” value=”5″> >40

</td>

</tr>

<tr>

<td><font face=”arial” size=”4″> 3. Nationality:</td>

<td><font face=”arial” size=”4″> <select name=”nationality”>

<option value=”option”>Country Options</option>
<option value=”Abkhazia”>Abkhazia</option>
<option value=”Afghanistan”>Afghanistan</option>
<option value=”AkrotiriandDhekelia”>Akrotiri and Dhekelia</option>
<option value=”Aland”>Åland</option>
<option value=”Albania”>Albania</option>
<option value=”Algeria”>Algeria</option>
<option value=”AmericanSamoa”>American Samoa</option>
<option value=”Andorra”>Andorra</option>
<option value=”Angola”>Angola</option>
<option value=”Anguilla”>Anguilla</option>
<option value=”AntiguaandBarbuda”>Antigua and Barbuda</option>
<option value=”Argentina”>Argentina</option>
<option value=”Armenia”>Armenia</option>
<option value=”Aruba”>Aruba</option>
<option value=”AscensionIsland”>Ascension Island</option>
<option value=”Australia”>Australia</option>
<option value=”Austria”>Austria</option>
<option value=”Azerbaijan”>Azerbaijan</option>
<option value=”BahamasThe”>Bahamas, The</option>
<option value=”Bahrain”>Bahrain</option>
<option value=”Bangladesh”>Bangladesh</option>
<option value=”Barbados”>Barbados</option>
<option value=”Belarus”>Belarus</option>
<option value=”Belgium”>Belgium</option>
<option value=”Belize”>Belize</option>
<option value=”Benin”>Benin</option>
<option value=”Bermuda”>Bermuda</option>
<option value=”Bhutan”>Bhutan</option>
<option value=”Bolivia”>Bolivia</option>
<option value=”Bosnia”>Bosnia</option>
<option value=”Botswana”>Botswana</option>
<option value=”Brazil”>Brazil</option>
<option value=”Brunei”>Brunei</option>
<option value=”Bulgaria”>Bulgaria</option>
<option value=”BurkinaFaso”>Burkina Faso</option>
<option value=”Burundi”>Burundi</option>
<option value=”Cambodia”>Cambodia</option>
<option value=”Cameroon”>Cameroon</option>
<option value=”Canada”>Canada</option>
<option value=”Cape”>Cape <option value=””>Verde</option>
<option value=”CaymanIslands”>Cayman Islands</option>
<option value=”CentralAfricanRepublic”>Central African Republic</option>
<option value=”Chad”>Chad</option>
<option value=”Chile”>Chile</option>
<option value=”China”>China</option>
<option value=”ChristmasIsland”>Christmas Island</option>
<option value=”CocosKeelingIslands”>Cocos (Keeling) Islands</option>
<option value=”Colombia”>Colombia</option>
<option value=”Comoros”>Comoros</option>
<option value=”CongoRepublica”>Congo (República)</option>
<option value=”CongoRepúblicaDemocratica”>Congo (República Democrática)</option>
<option value=”CookIslands”>Cook Islands</option>
<option value=”CostaRica”>Costa Rica</option>
<option value=”Côte d’Ivoire”>Côte d’Ivoire</option>
<option value=”Croatia”>Croatia</option>
<option value=”Cuba”>Cuba</option>
<option value=”Cyprus”>Cyprus</option>
<option value=”CzechRepublic”>Czech Republic</option>
<option value=”Denmark”>Denmark</option>
<option value=”Djibouti”>Djibouti</option>
<option value=”Dominica”>Dominica</option>
<option value=”DominicanRepublic”>Dominican Republic</option>
<option value=”EastTimor”>East Timor</option>
<option value=”Ecuador”>Ecuador</option>
<option value=”Egypt”>Egypt</option>
<option value=”ElSalvador”>El Salvador</option>
<option value=”EquatorialGuinea”>Equatorial Guinea</option>
<option value=”Eritrea”>Eritrea</option>
<option value=”Estonia”>Estonia</option>
<option value=”Ethiopia”>Ethiopia</option>
<option value=”FalklandIslands”>Falkland Islands</option>
<option value=”FaroeIslands”>Faroe Islands</option>
<option value=”Fiji”>Fiji</option>
<option value=”Finland”>Finland</option>
<option value=”France”>France</option>
<option value=”FrenchPolynesia”>French Polynesia</option>
<option value=”Gabon”>Gabon</option>
<option value=”GambiaThe”>Gambia, The</option>
<option value=”Georgia”>Georgia</option>
<option value=”Germany”>Germany</option>
<option value=”Ghana”>Ghana</option>
<option value=”Gibraltar”>Gibraltar</option>
<option value=”Greece”>Greece</option>
<option value=”Greenland”>Greenland</option>
<option value=”Grenada”>Grenada</option>
<option value=”Guam”>Guam</option>
<option value=”Guatemala”>Guatemala</option>
<option value=”Guernsey”>Guernsey</option>
<option value=”Guinea”>Guinea</option>
<option value=”GuineaBissau”>Guinea-Bissau</option>
<option value=”Guyana”>Guyana</option>
<option value=”Haiti”>Haiti</option>
<option value=”Honduras”>Honduras</option>
<option value=”HongKong”>Hong Kong</option>
<option value=”Hungary”>Hungary</option>
<option value=”Iceland”>Iceland</option>
<option value=”India”>India</option>
<option value=”Indonesia”>Indonesia</option>
<option value=”Iran”>Iran</option>
<option value=”Iraq”>Iraq</option>
<option value=”Ireland”>Ireland</option>
<option value=”IsleofMan”>Isle of Man</option>
<option value=”Israel”>Israel</option>
<option value=”Italy”>Italy</option>
<option value=”Jamaica”>Jamaica</option>
<option value=”Japan”>Japan</option>
<option value=”Jersey”>Jersey</option>
<option value=”Jordan”>Jordan</option>
<option value=”Kazakhstan”>Kazakhstan</option>
<option value=”Kenya”>Kenya</option>
<option value=”Kiribati”>Kiribati</option>
<option value=”KoreaNorth”>Korea, North</option>
<option value=”KoreaSouth”>Korea, South</option>
<option value=”Kosovo”>Kosovo</option>
<option value=”Kuwait”>Kuwait</option>
<option value=”Kyrgyzstan”>Kyrgyzstan</option>
<option value=”Laos”>Laos</option>
<option value=”Latvia”>Latvia</option>
<option value=”Lebanon”>Lebanon</option>
<option value=”Lesotho”>Lesotho</option>
<option value=”Liberia”>Liberia</option>
<option value=”Libya”>Libya</option>
<option value=”Liechtenstein”>Liechtenstein</option>
<option value=”Lithuania”>Lithuania</option>
<option value=”Luxembourg”>Luxembourg</option>
<option value=”Macau”>Macau</option>
<option value=”Macedonia”>Macedonia</option>
<option value=”Madagascar”>Madagascar</option>
<option value=”Malawi”>Malawi</option>
<option value=”Malaysia”>Malaysia</option>
<option value=”Maldives”>Maldives</option>
<option value=”Mali”>Mali</option>
<option value=”Malta”>Malta</option>
<option value=”MarshallIslands”>Marshall Islands</option>
<option value=”Mauritania”>Mauritania</option>
<option value=”Mauritius”>Mauritius</option>
<option value=”Mayotte”>Mayotte</option>
<option value=”Mexico”>Mexico</option>
<option value=”Micronesia”>Micronesia</option>
<option value=”Moldova”>Moldova</option>
<option value=”Monaco”>Monaco</option>
<option value=”Mongolia”>Mongolia</option>
<option value=”Montenegro”>Montenegro</option>
<option value=”Montserrat”>Montserrat</option>
<option value=”Morocco”>Morocco</option>
<option value=”Mozambique”>Mozambique</option>
<option value=”Myanmar (Burma)”>Myanmar (Burma)</option>
<option value=”Nagorno-Karabakh”>Nagorno-Karabakh</option>
<option value=”Namibia”>Namibia</option>
<option value=”Nauru”>Nauru</option>
<option value=”Nepal”>Nepal</option>
<option value=”Netherlands”>Netherlands</option>
<option value=”NetherlandsAntilles”>Netherlands Antilles</option>
<option value=”NewCaledonia”>New Caledonia</option>
<option value=”NewZealand”>New Zealand</option>
<option value=”Nicaragua”>Nicaragua</option>
<option value=”Niger”>Niger</option>
<option value=”Nigeria”>Nigeria</option>
<option value=”Niue”>Niue</option>
<option value=”NorfolkIsland”>Norfolk Island</option>
<option value=”NorthernCyprus”>Northern Cyprus</option>
<option value=”NorthernMarianaIslands”>Northern Mariana Islands</option>
<option value=”Norway”>Norway</option>
<option value=”Oman”>Oman</option>
<option value=”Pakistan”>Pakistan</option>
<option value=”Palau”>Palau</option>
<option value=”Palestine”>Palestine</option>
<option value=”Panama”>Panama</option>
<option value=”PapuaNewGuinea”>Papua New Guinea</option>
<option value=”Paraguay”>Paraguay</option>
<option value=”Peru”>Peru</option>
<option value=”Philippines”>Philippines</option>
<option value=”PitcairnIslands”>Pitcairn Islands</option>
<option value=”Poland”>Poland</option>
<option value=”Portugal”>Portugal</option>
<option value=”PuertoRico”>Puerto Rico</option>
<option value=”Qatar”>Qatar</option>
<option value=”Romania”>Romania</option>
<option value=”Russia”>Russia</option>
<option value=”Rwanda”>Rwanda</option>
<option value=”SaintBarthélemy”>Saint Barthélemy</option>
<option value=”SaintHelena”>Saint Helena</option>
<option value=”SaintKittsandNevis”>Saint Kitts and Nevis</option>
<option value=”SaintLucia”>Saint Lucia</option>
<option value=”SaintMartin”>Saint Martin</option>
<option value=”SaintPierreandMiquelon”>Saint Pierre and Miquelon</option>
<option value=”SaintVincentandtheGrenadines”>Saint Vincent and the Grenadines</option>
<option value=”Samoa”>Samoa</option>
<option value=”SanMarino”>San Marino</option>
<option value=”SãoToméandPríncipeSão”>São Tomé and Príncipe São</option>
<option value=”SaudiArabia”>Saudi Arabia</option>
<option value=”Senegal”>Senegal</option>
<option value=”Serbia”>Serbia</option>
<option value=”Seychelles”>Seychelles</option>
<option value=”SierraLeone”>Sierra Leone</option>
<option value=”Singapore”>Singapore</option>
<option value=”Slovakia</”>Slovakia</option>
<option value=”Slovenia”>Slovenia</option>
<option value=”Solomon Islands”>Solomon Islands</option>
<option value=”Somalia”>Somalia</option>
<option value=”Somaliland”>Somaliland</option>
<option value=”SouthAfrica”>South Africa</option>
<option value=”SouthOssetia”>South Ossetia</option>
<option value=”Spain”>Spain</option>
<option value=”SriLanka”>Sri Lanka</option>
<option value=”Sudan”>Sudan</option>
<option value=”Suriname”>Suriname</option>
<option value=”Svalbard”>Svalbard</option>
<option value=”Swaziland”>Swaziland</option>
<option value=”Sweden”>Sweden</option>
<option value=”Switzerland”>Switzerland</option>
<option value=”Syria”>Syria</option>
<option value=”Taiwan”>Taiwan</option>
<option value=”Tajikistan”>Tajikistan</option>
<option value=”Tanzania”>Tanzania</option>
<option value=”Thailand”>Thailand</option>
<option value=”Togo”>Togo</option>
<option value=”Tokelau”>Tokelau</option>
<option value=”Tonga”>Tonga</option>
<option value=”Transnistria”>Transnistria</option>
<option value=”TrinidadandTobago”>Trinidad and Tobago</option>
<option value=”TristandaCunha”>Tristan da Cunha</option>
<option value=”Tunisia”>Tunisia</option>
<option value=”Turkey”>Turkey</option>
<option value=”Turkmenistan”>Turkmenistan</option>
<option value=”TurksandCaicosIslands”>Turks and Caicos Islands</option>
<option value=”Tuvalu”>Tuvalu</option>
<option value=”Uganda”>Uganda</option>
<option value=”Ukraine”>Ukraine</option>
<option value=”UnitedArabEmirates”>United Arab Emirates</option>
<option value=”UnitedKingdom”>United Kingdom</option>
<option value=”UnitedStatesofAmerica”>United States of America</option>
<option value=”Uruguay”>Uruguay</option>
<option value=”Uzbekistan”>Uzbekistan</option>
<option value=”Vanuatu”>Vanuatu</option>
<option value=”VaticanCity”>Vatican City</option>
<option value=”Venezuela”>Venezuela</option>
<option value=”Vietnam”>Vietnam</option>
<option value=”Virgin IslandsBritish”>Virgin Islands, British</option>
<option value=”VirginIslandsUnited States”>Virgin Islands, United States</option>
<option value=”WallisandFutuna”>Wallis and Futuna</option>
<option value=”WesternSahara”>Western Sahara</option>
<option value=”Yemen”>Yemen</option>
<option value=”Zambia”>Zambia</option>
<option value=”Zimbabwe”>Zimbabwe</option>

</td>

</tr>
</h2>
</table>

<br>
<H3> <i> Part B. Motivation <u>to Use</u> or <u>Not to Use</u> the SMS-based System for Public Services </i> </H3>

<table>
<tr>
<td><font face=”arial” size=”4″> 1. Are you aware of an SMS service for public services in your country?
&nbsp; &nbsp; &nbsp;
<input type=”radio” name=”use” value=”1″> YES

&nbsp;
<input type=”radio” name=”use” value=”0″> NO
</td>
</tr>

<tr>
<td><font face=”arial” size=”2″> <I> (*SMS service for public services’ is any public services provided by government
through Short Messanging Service channel, for example sending complain/report
to government via SMS, obtaining information about Bus timetable using SMS,
paying tax via SMS, etc) </I>
<br>&nbsp;
</td>

</tr>

<tr>
<td><font face=”arial” size=”4″> 2. Have you ever used the SMS service?:
&nbsp; &nbsp; &nbsp;

<input type=”radio” name=”pakai” value=”1″> YES (go to Question 3)
&nbsp;
<input type=”radio” name=”pakai” value=”0″> NO (go to Question 4)<br>&nbsp; </td>

</tr>
<tr><br> </tr>

<tr >

<td><font face=”arial” size=”4″> 3. If <b>YES</b>, why did you use the service:
<br>&nbsp; &nbsp;
<textarea rows=”4″ cols=”100″ name=”reasonyes”></textarea></td>
</tr>

<tr>

<td><font face=”arial” size=”4″> 4. If <b>NO</b>, why did NOT you use the service:
<br>&nbsp; &nbsp;
<textarea rows=”4″ cols=”100″ name=”reasonno”></textarea></td>

</tr>

<tr>

<td><font face=”arial” size=”4″> 5. Who is/are <b>person(s) who influenced you </b>to use or not to use the service?(if any):
<br>&nbsp; &nbsp;
<textarea rows=”2″ cols=”100″ name=”personinfluence”></textarea></td>

</tr>
</table>

<br><font face=”arial” size=”4″>
<center> <input type=”submit” value=”DONE & SUBMIT”><br>

<i> Thank You Very Much for Your Time and Participation </i>     </center>
</font>
</form>

</BODY>

</HTML>

——————————————————————————–

2. to create a table in MySQL: table “survey1” in database “smsegov”

using PHPmyAdmin application I create the table:

tablesurvey1

* Note: change the field ‘use’ to other name, e.g. “pakai”

——————————————————————————

3. To create a PHP file to insert the input data  to Database (mySQL)

<?php

$host=”localhost”;
$user=”root”;
$pass=”yourpassword”;
$db=”smsegov”;
$tbl=”survey1″;

// Connect to server and select database.
mysql_connect(“$host”, “$user”, “$pass”)or die(“cannot connect”);
mysql_select_db(“$db”)or die(“cannot select DB”);

// Get values from form
$sex= $_POST[‘sex’];
$age= $_POST[‘age’];
$nationality= $_POST[‘nationality’];
$aware= $_POST[‘aware’];
$pakai= $_POST[‘pakai’];
$reasonno= $_POST[‘reasonno’];
$reasonyes= $_POST[‘reasonyes’];
$personinfluence= $_POST[‘personinfluence’];

// Insert data into mysql
$sql=”INSERT INTO $tbl (datetime,sex,age,nationality,aware,pakai,reasonyes,reasonno,personinfluence)VALUES(sysdate(),’$sex’,’$age’,’$nationality’,’$aware’,’$pakai’,’$reasonyes’,’$reasonno’,’$personinfluence’)”;
$result=mysql_query($sql);

// if successfully insert data into database, displays message “Successful”.
if($result){
echo “Successful”;
echo “<BR>”;
echo “<a href=’formsurvey1.html’>Back to form</a>”;
}

else
die (“MySQL gagal karena”.mysql_error());

// close connection
mysql_close();

?>


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: