close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Redirect on Insert

Thread began 7/04/2012 9:22 am by dallySP | Last modified 7/05/2012 11:48 am by dallySP | 979 views | 2 replies |

dallySP

Redirect on Insert

I'm having problems getting my page to redirect after insert with a query string. I don't know why as I've done this loads of times before but having spent the last couple of hours trying to dissect the code thought I'd ask you. I'm sure its something realy obvious. The insert page carries a query string eg. deck_Insert.php?ProjectID=1 and I want the page to go back to the project_Detail.php?ProjectID=1 page after insert. It works fine on the cancel, update page etc, but not the insert. Code is as follows:
<?php
$projectparam_rsProject = "-1";
if (isset($_GET['ProjectID'])) {
$projectparam_rsProject = (get_magic_quotes_gpc()) ? $_GET['ProjectID'] : addslashes($_GET['ProjectID']);
}
mysql_select_db($database_cmsconn, $cmsconn);
$query_rsProject = sprintf("SELECT * FROM project WHERE ProjectID=%s", GetSQLValueString($projectparam_rsProject, "int"));
$rsProject = mysql_query($query_rsProject, $cmsconn) or die(mysql_error());
$row_rsProject = mysql_fetch_assoc($rsProject);
$totalRows_rsProject = mysql_num_rows($rsProject);?>
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $cmsconn;
$WA_table = "deck";
$WA_sessionName = "WADA_Insert_deck";
$WA_redirectURL = "project_Detail.php?ProjectID=".$row_rsProject['ProjectID'] ."";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "DeckID";
$WA_fieldNamesStr = "DeckName|DeckAbbrev|DeckProjectID";
$WA_fieldValuesStr = "".((isset($_POST["DeckName"]))?$_POST["DeckName"]:"") ."" . "|" . "".((isset($_POST["DeckAbbrev"]))?$_POST["DeckAbbrev"]:"") ."" . "|" . "".((isset($_POST["DeckProjectID"]))?$_POST["DeckProjectID"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_cmsconn;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

use the following code for the forms action to ensure that the query string being used to load the page is also passed when the form is submitted:

php:
 action="<?php echo(htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)."?".$_SERVER["QUERY_STRING"]); ?>"
Sign in to reply to this post

dallySP

That worked a treat - thank you so much

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...