View Full Version : Using mysql to connect to database and send to thank you page.

08-13-2007, 08:36 PM
Hello I have a problem with the mysql and PHP coding. The problem is when a person types the information and click on the submit button on the web site. The submit button should take you to a thank you page. Instead the submit button returns you to the same page. The address of the problem page is http://www.honorpac.org/rsvp/rsvp.php The designer used the edit form action with htmlentities and in the mysql select db coding it has a insert GoTo=”thankyou.html”;. How can I have the submit button take you to the thank you page?

Actual Coding from the web site:

<?php require_once('../Connections/contributions.php'); ?><?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
return $theValue;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction . = "?" . htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "contributions")) {
$insertSQL = sprintf("INSERT INTO contributions (name, address, city, `state`, zip, occupation, employer, contribution, recurring_amount, guests, member, cc_name, cc_exp_mon, cc_exp_yr, cc_no, cc_type, cc_addy, cc_city, cc_state, cc_zip, phone, fax, cell, email, comments, date_submitted, reffering_page) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['zip'], "text"),
GetSQLValueString($_POST['occupation'], "text"),
GetSQLValueString($_POST['employer'], "text"),
GetSQLValueString($_POST['contribution'], "text"),
GetSQLValueString($_POST['recurring_amount'], "text"),
GetSQLValueString($_POST['guests'], "text"),
GetSQLValueString($_POST['member'], "text"),
GetSQLValueString($_POST['cc_name'], "text"),
GetSQLValueString($_POST['cc_exp_mon'], "text"),
GetSQLValueString($_POST['cc_exp_yr'], "text"),
GetSQLValueString($_POST['cc_no'], "text"),
GetSQLValueString($_POST['cc_type'], "text"),
GetSQLValueString($_POST['cc_addy'], "text"),
GetSQLValueString($_POST['cc_city'], "text"),
GetSQLValueString($_POST['cc_state'], "text"),
GetSQLValueString($_POST['cc_zip'], "text"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['fax'], "text"),
GetSQLValueString($_POST['cell'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['comments'], "text"),
GetSQLValueString($_POST['date_submitted'], "date"),
GetSQLValueString($_POST['reffering_page'], "text"));

mysql_select_db($database_contributions, $contributions);
$Result1 = mysql_query($insertSQL, $contributions) or die(mysql_error());
$insertGoTo ="thankyou.html";}

<!-- End Left Rail--><!-- Content Section -->
<td align="left" valign="top" bgcolor="#fcf0c7"><!-- InstanceBeginEditable name="Region" -->
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="contributions" id="contributions" onsubmit="return checkFields();">
<input name="reffering_page" type="hidden" id="reffering_page" value="Yacht Cruise" /> <input type="hidden" name="date_submitted" value="<?php echo date('Y-m-d H:i:s') ?>" />
<table width="675" border="0" cellspacing="0" cellpadding="3">

08-14-2007, 03:21 PM

u need to add the following line at...

$Result1 = mysql_query($insertSQL, $contributions) or die(mysql_error());
$insertGoTo ="thankyou.html";
//new code must go here
header("Location: $insertGoTo");

and as long as no error are produced your page will navigate to the thankyou.html page.