Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Record - redirect to page with same record

Status
Not open for further replies.

multipleintell

Technical User
Dec 7, 2001
72
0
0
US
I want to allow the user to insert a record, then pass a parameter to the redirect page to display the record's information.

I want to put a parameter here, but it finds no record even though the record does successfully insert into my database:

$insertGoTo = "/TalentDetail.php?TalentID=<?php echo $row_SelectTalentName['TalentID'];?>";


Here is my current code:

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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form3")) {
$insertSQL = sprintf("INSERT INTO talenttbl (TalentID, LName, FName, DOB, ChildSize, Inseam, Dress, Shoe, Shirt, Suit, Chest, Hips, Waist, Height, Division, HairColor, EyeColor) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['TalentID'], "int"),
GetSQLValueString($HTTP_POST_VARS['LName'], "text"),
GetSQLValueString($HTTP_POST_VARS['FName'], "text"),
GetSQLValueString($HTTP_POST_VARS['DOB'], "date"),
GetSQLValueString($HTTP_POST_VARS['ChildSize'], "text"),
GetSQLValueString($HTTP_POST_VARS['Inseam'], "double"),
GetSQLValueString($HTTP_POST_VARS['Dress'], "text"),
GetSQLValueString($HTTP_POST_VARS['Shoe'], "double"),
GetSQLValueString($HTTP_POST_VARS['Shirt'], "int"),
GetSQLValueString($HTTP_POST_VARS['Suit'], "text"),
GetSQLValueString($HTTP_POST_VARS['Chest'], "double"),
GetSQLValueString($HTTP_POST_VARS['Hips'], "double"),
GetSQLValueString($HTTP_POST_VARS['Waist'], "double"),
GetSQLValueString($HTTP_POST_VARS['Height'], "double"),
GetSQLValueString($HTTP_POST_VARS['Division'], "text"),
GetSQLValueString($HTTP_POST_VARS['HairColor'], "text"),
GetSQLValueString($HTTP_POST_VARS['EyeColor'], "text"));

mysql_select_db($database_ImageNetfirms, $ImageNetfirms);
$Result1 = mysql_query($insertSQL, $ImageNetfirms) or die(mysql_error());

$insertGoTo = "/TalentDetail.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
 
Genral appraoch to sequential record creation & display:

page 1====
-form
-hidden field = "current/last exisitng recordID"

page2======
-insert action
-varID = request:"hidden field"
VAR_lastInserted=varID+1
-filter recordset/array with "VAR_lastInserted" and display the last inserted/created record.

sorry no PHP code
HTH
All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top