I just couldnt find a soluation for this.
How to insert a one record inside one forum with muliple sql tables in one php page?
Here is my code i have two insert button, i only need one for the both form
<?php require_once('Connections/Omar.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 customers (customer_name_arabic, customer_name_english) VALUES (%s, %s)",
GetSQLValueString($_POST['customer_name_arabic'], "text"),
GetSQLValueString($_POST['customer_name_english'], "text"));
mysql_select_db($database_Omar, $Omar);
$Result1 = mysql_query($insertSQL, $Omar) or die(mysql_error());
$insertGoTo = "view.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO land_master (area, plot_number, isblocked) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['area'], "text"),
GetSQLValueString($_POST['plot_number'], "text"),
GetSQLValueString($_POST['isblocked'], "int"));
mysql_select_db($database_Omar, $Omar);
$Result1 = mysql_query($insertSQL, $Omar) or die(mysql_error());
$insertGoTo = "details.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>