Jump to content

Passing data between pages help - works until I add some validation


BarneyJoe

Recommended Posts

Hope someone can help with this, as the two steps forward one step back thing is starting to make my brain turn to mush!

I have standard form where users input various data - when this is completed it takes them to a second page where they can add keywords to the record by checking various boxes.

This all works fine with the form page, and the add keywords page.

The add keywords page contains the code to insert the fields form the preceding form page :

[code]<?php
mysql_select_db($database_Photolibrary, $Photolibrary);
$query_Recordset1 = "SELECT * FROM photos";
$Recordset1 = mysql_query($query_Recordset1, $Photolibrary) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php

move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'], "Photos/{$_FILES['uploadFile'] ['name']}")

?>
<?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;
}

/********************
*
*insert Vacancy details into db
*
********************/

//sql string

  $insertSQL = sprintf("INSERT INTO Photos (Link_ID, Title, Rights, Rights_Details, Credit, Image_Size, Year, Supplier, Photo_File, Orientation, Admin, Region, Country, Easting, Northing) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                      GetSQLValueString($_POST['Link_ID'], "text"),
                      GetSQLValueString($_POST['Title'], "text"),
                      GetSQLValueString($_POST['Rights'], "text"),
                      GetSQLValueString($_POST['Rights_Details'], "text"),
          GetSQLValueString($_POST['Credit'], "text"),
          GetSQLValueString($_POST['Image_Size'], "text"),
                      GetSQLValueString($_POST['Year'], "text"),
                      GetSQLValueString($_POST['Supplier'], "text"),
                      GetSQLValueString($_FILES['uploadFile']['name'], "text"),
          GetSQLValueString($_POST['Orientation'], "text"),
                      GetSQLValueString($_POST['Admin'], "text"),
                      GetSQLValueString($_POST['Region'], "text"),
                      GetSQLValueString($_POST['Country'], "text"),
          GetSQLValueString($_POST['Easting'], "text"),
                      GetSQLValueString($_POST['Northing'], "text"));
                     

//insert

$Result1 = mysql_select_db($database_Photolibrary, $Photolibrary); mysql_query($insertSQL); echo mysql_error();

/********************
*
*Retrieve PhotoID
*
********************/

$Photo_ID = mysql_insert_id ();

?>[/code]

However, if i change the form page to point first to my validation.php, rather than the add keywords page, with it only progressing to that page if the form validates, then the date isn't being carried through.

What code do I need to add to the validation page to pass it through to the add keywords page?

Cheers,
Iain

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.