Problem : i have three forms on three different files, personal_details, property_details and payment. After clicking the submit button on the personal details form the property details form opens as expected but upon clicking the submit form button on the property details form the payment form does not open.
If there's a way out i would appreciate this very much

the files are as follows;

personal details

<?php require_once('Connections/estate1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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 personaldetails (regID, firstname, lastname, sex, stateoforigin, email, telephone, username, password, useraccess) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['regID'], "int"),
                       GetSQLValueString($_POST['firstname'], "text"),
                       GetSQLValueString($_POST['lastname'], "text"),
                       GetSQLValueString($_POST['sex'], "text"),
                       GetSQLValueString($_POST['stateoforigin'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['telephone'], "text"),
                       GetSQLValueString($_POST['username'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['useraccess'], "text"));

  mysql_select_db($database_estate1, $estate1);
  $Result1 = mysql_query($insertSQL, $estate1) or die(mysql_error());

  $insertGoTo = "property_details.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

property details

<?php require_once('Connections/estate1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO propertydetails (propertyID, price, regID, cooNo, propType, intent, numofrooms, address, `state`, lga) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['propertyID'], "int"),
                       GetSQLValueString($_POST['price'], "int"),
                       GetSQLValueString($_POST['regID'], "text"),
                       GetSQLValueString($_POST['cooNo'], "text"),
                       GetSQLValueString($_POST['proptype'], "text"),
                       GetSQLValueString($_POST['intent'], "text"),
                       GetSQLValueString($_POST['numofrooms'], "text"),
                       GetSQLValueString($_POST['address'], "text"),
                       GetSQLValueString($_POST['state'], "text"),
                       GetSQLValueString($_POST['lga'], "text"));

  mysql_select_db($database_estate1, $estate1);
  $Result1 = mysql_query($insertSQL, $estate1) or die(mysql_error());

  $insertGoTo = "payment.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

payment

<?php require_once('Connections/estate1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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"] == "form3")) {
  $insertSQL = sprintf("INSERT INTO payment (paymentID, propertyID, cardType, `number`, securitycode, postcode, cardexp, email, regID) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['paymentID'], "int"),
                       GetSQLValueString($_POST['propertyID'], "int"),
                       GetSQLValueString($_POST['cardType'], "text"),
                       GetSQLValueString($_POST['number'], "int"),
                       GetSQLValueString($_POST['securitycode'], "int"),
                       GetSQLValueString($_POST['postcode'], "text"),
                       GetSQLValueString($_POST['cardexp'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['regID'], "int"));

  mysql_select_db($database_estate1, $estate1);
  $Result1 = mysql_query($insertSQL, $estate1) or die(mysql_error());

  $insertGoTo = "logging.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

Edited 3 Years Ago by Nick Evan: Fixed formatting

Hi,I have seen your whole coding and i cant found little mistake in that.but may be its header transfer problem

try following code for header transfer in property details.php

$insertGoTo = "payment.php";
if (isset($_SERVER)) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER;
}
header("location:".$insertGoTo);
}

instead of header(sprintf("Location: %s", $insertGoTo));

I m not sure your problem will solve or not but may be it will help you.

best luck

thanks Will try that.
Right not i started right from the beginning and been trying to request a primary field entry made in the first form so i can input its value in the second form as it is a foreign key in the second and third forms.

tried;
$query = "select regID from personal where email=$_POST[email]";
$result = msql_query($query) or die("this query failed");

while($row=msql_fetch_assoc($result))
{
$regID=$row["regID"];
}

but apparently it's not getting the primary key as the foreign key is not getting the same value as the primary key in other table, used auto increment for the primary key.

Thanks again

This article has been dead for over six months. Start a new discussion instead.