This topic is locked

After record adding record not redirecting

9/21/2011 3:04:37 AM
PHPRunner General questions
author

Hey i have a problem with after record adding record not redirecting
Hear is my coding for redirecting.. when i add a record it will stay same a s it is ...
this coding is working very well
header("Location: Spec_Kids_Head_list.php?a=return");

exit();
global $conn;
$strSQLExists = "select FROM Spec_Kids_Head Where Internal='".$keys["Internal"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data3=db_fetch_array($rsExists);
if($_SESSION["copyid1"] == "")

{
$strSQLExists = "select
FROM Spec_Kids ";

$rsExists = db_query($strSQLExists,$conn);

while($data4=db_fetch_array($rsExists))

{
$strSQLInsert = "INSERT INTO Sp_Kitem SET

Internal='".$data3['Internal']."',

Group_ID='".$data4['Abbr']."',

Group_Item='".$data4['Item']."'";
db_exec($strSQLInsert,$conn);
//////////////////
}
$strSQLExists = "select Max(Spec_No) as maxsp FROM Spec_Info_Types ";

$rsExists = db_query($strSQLExists,$conn);

$data5=db_fetch_array($rsExists);
$max1=$data5["maxsp"]+1;
$type="Kids";
$strSQLInsert = "Update Spec_Kids_Head SET Spec_No='".$max1."',Spec_Revise='0',Spec_type='".$type."' where Internal='".$keys["Internal"]."' ";
//echo $strSQLInsert;

db_exec($strSQLInsert,$conn);

//////////////////////////////////////////////////////////

$strSQLInsert = "INSERT INTO Spec_Info_Types SET

Spec_No='".$max1."',

Type='".$type."',

Spec_internal='".$keys['Internal']."'";
//echo $strSQLInsert;

db_exec($strSQLInsert,$conn);

}

//echo $_SESSION["copyid1"];

//if($_SESSION["copyid1"] !="")

//{

$strSQLExists = "select FROM Sp_Kitem where Internal ='".$_SESSION["copyid1"]."'";

//echo $strSQLExists;

$rsExists = db_query($strSQLExists,$conn);

while($data4=db_fetch_array($rsExists))

{
$strSQLInsert = "INSERT INTO Sp_Kitem SET

Internal='".$values["Internal"]."',

Group_ID='".$data4['Group_ID']."',

Model='".$data4['Model']."',

Description='".addslashes($data4['Description'])."',

Des_Chinese='".addslashes($data4['Des_Chinese'])."',

Maker='".addslashes($data4["Maker"])."',

Col1='".addslashes($data4['Col1'])."',

Col2='".addslashes($data4['Col2'])."',

Col3='".addslashes($data4['Col3'])."',

SubItem1='".addslashes($data4['SubItem1'])."',

SubItem2='".addslashes($data4['SubItem2'])."',

SubItem3='".addslashes($data4['SubItem3'])."',

SubItem4='".addslashes($data4['SubItem4'])."',

Subitem5='".addslashes($data4['Subitem5'])."',

SubItem6='".addslashes($data4['SubItem6'])."',

Subval1='".addslashes($data4['Subval1'])."',

Subval2='".addslashes($data4['Subval2'])."',

Subval3='".addslashes($data4['Subval3'])."',

Subval4='".addslashes($data4['Subval4'])."',

Subval5='".addslashes($data4['Subval5'])."',

Subval6='".addslashes($data4['Subval6'])."',

Group_Item='".$data4['Group_Item']."'";
echo $strSQLInsert;

db_exec($strSQLInsert,$conn);
}

if($_SESSION["copyid1"] != "")

{

$strSQLExists = "select
FROM Spec_Kids_Head where Internal ='".$_SESSION["copyid1"]."'";

//echo $strSQLExists;

$rsExists = db_query($strSQLExists,$conn);

$data6=db_fetch_array($rsExists);
$strSQLInsert = "Update Spec_Kids_Head SET Spec_No='".$data6["Spec_No"]."' where Internal ='".$values["Internal"]."' ";
//echo $strSQLInsert;

db_exec($strSQLInsert,$conn);
$strSQLExists = "select Max(Spec_Revise) as maxr FROM Spec_Kids_Head where Spec_No='".$data6["Spec_No"]."'";

//echo $strSQLExists;

$rsExists = db_query($strSQLExists,$conn);

$data7=db_fetch_array($rsExists);
$revise=$data7["maxr"]+1;

$type="Kids";
$strSQLInsert = "Update Spec_Kids_Head SET Spec_Revise='".$revise."',Spec_type='".$type."' where Internal ='".$values["Internal"]."' ";
//echo $strSQLInsert;

db_exec($strSQLInsert,$conn);
}
$_SESSION["copyid1"] ="";
plzzzzzzzzzzzzzzzzz help me to after record adding to redirecting to list page..
how should i change my coding

C
cgphp 9/21/2011

You have to place the redirection at the end of the "After record added" event:

header("Location: Spec_Kids_Head_list.php?a=return");

exit();



Comment out all echos in your code.