Hi guys
the submit button does not process the information from the 4 text fields, I have included code below:
An help would be great......
thanks in advance
<?php
//Application: Survey
//Purpose: This is the main page of the survey application. It prints
//out the survey form (which posts to thanks.php), as well as a link
//to the main results page (results.php).
//It is accessed directly by the user.
include "header.php";
//include"db.php";
include "start_page.php";
include "functions.php";
include "config1.php";
?>
<CENTER>
<IMG SRC="world.jpg" ALT=""></img>
<p>
Thanks for filling out the survey. Be sure to fill out all the questions,
and become eligible for our weekly prize drawings!
Please, only one entry per person.
</p>
<p>
</p>
<BR><BR><BR><BR>
</CENTER>
<?php
// begin the survey form.
print start_form("thanks.php");
// get the current survey questions from the database and display
// them to the user for voting.
print subtitle("Start the questions:");
$query = "select question_id, question from questions q order by question_id";
$result = safe_query($query);
// set the name of each question and each answer field
// in the "field[]" format. PHP will treat the values
// of these fields as arrays when the form is submitted.
// we start the field index at 1 to avoid any problems
// with the index seeming to be empty.
$i = 1;
while (list($question_id, $question) = mysql_fetch_row($result))
{
// use the db_radio_field() function (defined in
// /book/functions/forms.php) to construct a list
// of radio fields for each answer to the question.
print paragraph(
"<b>$question:</b><br>"
, hidden_field("question_id[$i]", $question_id)
, db_radio_field("answer_id[$i]"
, "answers", "answer_id", "answer", "answer_id"
, "" // no matching value
, "question_id = $question_id"
)
);
$i++;
}
print "<BR><BR>";
// print out fields for the user to fill in.
print subtitle("Please enter your personal details:");
?>
<html>
<head>
<!-- <title><?php print $title ?></title>-->
<form action="<?=$_SERVER["PHP_SELF"]?>" method="POST">
<table>
<tr><td>Name:</td><td><input type="text" name="name" value=""
<?php print isset($_POST["name"]) ? $_POST["name"] : "" ;?>"
maxlength="15"></td></tr>
<tr><td>Email</td><td><input type="text" name="email" value="" maxlength="25"></td></tr>
<tr><td>Confirm Email </td><td><input type="text" name="email2" value="" maxlength="25"></td></tr>
<tr><td>Age </td><td><input type="text" name="age" value="" maxlength="3"></td></tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST["submit"]))
{
// Info has been submitted, check it:
// Check login, password and password2 are not empty:
#field_validator($field_descr, $field_data, $field_type, $min_length="", $max_length="", $field_required=1)
{
field_validator("name", $_POST["name"], "alphanumeric", 4, 25);
field_validator("email", $_POST["email"], "string", 4, 25);
field_validator("email2", $_POST["email2"], "string", 4, 25);
field_validator("age", $_POST["age"], "string", 1, 3);
$query="SELECT guestbook2k FROM users WHERE name='".$_POST["name"]."'";
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error());
if(empty($messages))
{
// registration ok, get user id and update db with new info:
newUser($_POST["name"], $_POST["password"], $_POST["age"] );
}
}
}
if(strcmp($_POST["email"], $_POST["email2"]))
{
// The password and confirmation password didn't match,
// Add a message to be displayed to the user:
$messages[]="Your passwords did not match";
}
print paragraph(submit_field("submit","Submit Survey"), reset_field());
//end the survey form.
print end_form();
include "end_page.php";
//Check if $message is set, and output it if it is:
if(!empty($messages)){
displayErrors($messages);
}
?>