Form submit in PHP
Posted: Fri Apr 01, 2011 12:49 pm
I want to create a very simple database driven survey whose URL is accessed by a mobi Tag via a smart phone, filled out by users, and the results stored in the database. The survey questions can change with time. So the database has three tables: one containing the survey description and questions, one containing the options to the questions (multiple choice with buttons), and one containing the answers.
I create the form with questions and options with buttons, drawing the data from the database. The problem is that I cannot get the "submit" to work. No matter what I try, I get:
The requested URL /Espresso-Sites/mobitags/$_SERVER[ was not found on this server.
You can see it at work at this URL: http://www.ridgeviewvalley.com/testing/test.php
With or without the CSS file the result is the same. Below is the code.
I've been fighting this for two days. Can anyone help me?
Thanks
I create the form with questions and options with buttons, drawing the data from the database. The problem is that I cannot get the "submit" to work. No matter what I try, I get:
The requested URL /Espresso-Sites/mobitags/$_SERVER[ was not found on this server.
You can see it at work at this URL: http://www.ridgeviewvalley.com/testing/test.php
With or without the CSS file the result is the same. Below is the code.
I've been fighting this for two days. Can anyone help me?
Thanks
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>"Testing"</title>
</head>
<body>
<?php
// Create the form
$question = "How good is this?";
$option = array();
$option[0] = "This is good";
$option[1] = "This is better";
$option[2] = "This is best";
$number_options = 3;
$res = "\$_SERVER"."['PHP_SELF']";
echo($res . "</br>");
echo($_SERVER['PHP_SELF']);
echo("<form class='form' method='post' action='$res'>");
echo('<div class="questionblock">');
echo("<h3>".$question."</h3>");
/* echo("<p>".$number_options."</p>");*/
echo('<div class="optionblock">');
$j = 0;
while ($j < $number_options)
{
echo('<input class="optional" type="radio" name="option" value="option"/> <h5>' . $option[$j] . '</h5>');
$j++;
}
echo('<input class="submit" type="submit" name="Submit" value="Submit">');
echo("</div>");
echo("</div>");
echo("</form>");
echo($_POST['option']."</br>");
?>
</body>