PHP Code:
<?php
ob_start();
require_once ("../contactform1.php");
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"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clients_for_newsletter (first_name, second_name, company, email, web, tel, mobile, fax, Address, city, country, enquiries, checkbox) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['second_name'], "text"),
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['web'], "text"),
GetSQLValueString($_POST['tel'], "int"),
GetSQLValueString($_POST['mobile'], "int"),
GetSQLValueString($_POST['fax'], "int"),
GetSQLValueString($_POST['Address'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['enquiries'], "text"),
GetSQLValueString(isset($_POST['checkbox']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_contactform1, $contactform1);
$Result1 = mysql_query($insertSQL, $contactform1) or die(mysql_error());
}
$insertGoTo = "thankyou.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s",$insertGoTo));
exit()
?>
SpikeZ
Bookmarks