Hi and thanks for your replies.
And I am still getting know where. This is what I have so far.
FORM1 This is the user data entry form.
<form method="post" name="form2" action="second_form.php">
<table>
<tr>
<td>First Name:</td>
<td><input name="name" type="text" id="name" /></td>
</tr>
<tr>
<td>Surname:</td>
<td><input name="surname" type="text" id="surname" /></td>
</tr>
<tr>
<td</td>
<td><input type="submit" value="Book Now"></td>
</tr>
</table>
</form>
When the first form is sumbitted the SECOND FORM loads and the correct data is passed and is displayed.
FORM 2
<form method="post" name="form2" action="">
<table>
<tr>
<td>First Name:</td>
<td><?php print $name; ?></td>
</tr>
<tr>
<td>Surname:</td>
<td><?php print $surname; ?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="coursebodytext" value="Comfirm Provisional Reservation"></td>
</tr>
</table>
</form>
If the user agrees with the data they have input they click on the submit button which loads a third form and inserts the data into the database.
FORM3
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO int_course_booking ( first_name, surname) VALUES (%s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['surname'], "text"));
mysql_select_db($database_int_courses, $int_courses);
$Result1 = mysql_query($insertSQL, $int_courses) or die(mysql_error());
$insertGoTo = "international_intelligence_all_courses.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table>
<tr>
<td><div align="center">PROVISIONAL RESERVATION </div></td>
<tr>
<td>First Name:</td>
<td ><input name="first_name" type="text" value="><?php echo $_POST[ 'first_name' ]; ?>" size="4"></td>
</tr>
<tr>
<td>Surname:</td>
<td></td>
<td><input name="surname" type="text" value="><?php echo $_POST[ 'surname' ]; ?>" size="4"></td>
</tr>
<tr>
<td><input type="submit" value="Comfirm Provisional Reservation"></td>
</tr>
</table>
<input type="hidden" value="mailto:info@bytecweb.com" />
<input type="hidden" name="MM_insert" value="form2">
</form>
The problem I am having is that when the THIRD form is processed the data is not written in to the database.
Can anyone see what I am doingwrong, or am I doing this completly backwards.
Many thanks for any help you can give.