close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


redirecting to page with newly inserted row as a parameter

Thread began 5/08/2014 6:18 am by CraigR | Last modified 5/08/2014 11:24 am by Jason Byrnes | 358 views | 3 replies |

CraigRBeta Tester

redirecting to page with newly inserted row as a parameter

I have an admin form for storing member registrations.
Sometimes, there may be several people from the same organisation to add to the system so rather than re-key all of the data, I want to add a ‘duplicate’ button to a member update page, which will copy the fields from the existing form into the members table, then redirect to the new record so it can be edited.
In the Insert Record Server Behavior, I set the session name to be MemberID and then set the redirect URL to "../member_update.php?MemberID=".$_SESSION['MemberID'];

At first, I couldn’t get the session value to appear as the url parameter, so I added @session_start(); to line 1 of my page.

Now, I get a parameter, but the value is incorrect, the ID is 1 less than the value of the newly entered row


// WA DataAssist Insert
if (isset($_POST["duplicate"]) || isset($_POST["duplicate_x"])) // Trigger
$WA_connection $PowerCMSConnection;
$WA_table "tblmembers";
$WA_sessionName "MemberID";
$WA_redirectURL "../member_update.php?MemberID=".$_SESSION['MemberID'];
  if (
function_exists("rel2abs")) $WA_redirectURL $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString false;
$WA_fieldNamesStr "MemberGroupID|MemberUserName|MemberPassword|MemberFirstName|MemberLastName|userLevel|Display|Active";
$WA_fieldValuesStr "".((isset($_POST["MemberGroup"]))?$_POST["MemberGroup"]:"")  ."" $WA_AB_Split "".((isset($_POST["MemberUserName"]))?$_POST["MemberUserName"].'(Copy)':"")  ."" $WA_AB_Split "".((isset($_POST["StandardMemberPassword"]))?md5($_POST["StandardMemberPassword"]):"")  ."" $WA_AB_Split "".((isset($_POST["MemberFirstName"]))?$_POST["MemberFirstName"]:"")  ."" $WA_AB_Split "".((isset($_POST["MemberLastName"]))?$_POST["MemberLastName"]:"")  ."" $WA_AB_Split "".((isset($_POST["UserLevel"]))?$_POST["UserLevel"]:"")  ."" $WA_AB_Split "".((isset($_POST["chkdisplay"]))?$_POST["chkdisplay"]:"")  ."" $WA_AB_Split "".((isset($_POST["chkactive"]))?$_POST["chkactive"]:"")  ."";
$WA_columnTypesStr "none,none,NULL|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|none,none,NULL";
$WA_fieldNames explode("|"$WA_fieldNamesStr);
$WA_fieldValues explode($WA_AB_Split$WA_fieldValuesStr);
$WA_columns explode("|"$WA_columnTypesStr);
$WA_connectionDB $database_PowerCMSConnection;
$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($WA_connection);
  if (
$WA_redirectURL != "")  {
$WA_redirectURL str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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

set the redirect URL:
$WA_redirectURL = "../member_update.php?MemberID=".$_SESSION['MemberID'];

$WA_redirectURL = "../member_update.php?MemberID=[Insert_ID]";

notice this section of the code just before the header redirect:

$_SESSION[$WA_sessionName] = mysql_insert_id($WA_connection);

if ($WA_redirectURL != "") {

$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$WA_redirectURL);

the first line sets the session, then the 3rd line looks at the redirect URL and replaces [Insert_ID] with the session value.

Sign in to reply to this post

CraigRBeta Tester


Thanks Jason, its working great

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

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





Ease of use


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...