close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Update after Insert

Thread began 10/28/2011 10:30 am by anthony399409 | Last modified 11/01/2011 12:41 pm by Jason Byrnes | 4042 views | 10 replies |

anthony399409

Update after Insert

My form has several form fields, one of which is a select menu identified as 'State'. After submitting this form it will take the user to the next page where they will select their 'Location' based on their 'State'.

However, I'm having trouble getting the entry's ID to pass thru the URL to update the entry. I've been able to pass the 'State' entry with the URL and pull the 'Location' selections in, but that was by building a form outside of the WADA system. When I use the WADA system to build the forms I get the 'No Record Found' result.

If you want to see what I'm trying, you can go to ads_Insert.php

Sign in to reply to this post

Jason ByrnesWebAssist

Send a copy of your page and a screen shot demonstrating the problem in a zip archive, the link you provided is not working.

Sign in to reply to this post

anthony399409

I may have typed the URL wrong - ads_Insert.php

Sign in to reply to this post

Jason ByrnesWebAssist

you shouldn't be going directly form insert to update.


The data assist wizard will create a search and results and details page along with the insert, update and delete pages, the insert page should redirect to the detail page which will show the details of the record just inserted, from there, you can select to update it or delete it.

Sign in to reply to this post

anthony399409

I figured I would have to do that. I was wanting to eliminate an extra click for the end user. I used the ADDT for this the last time around, but since there is no more ADDT, the support for it is mostly gone.

When I used the ADDT I was able to pass the newly inserted record's ID to the next page, but this one isn't working the same way.

Thanks for the reply!

Sign in to reply to this post

Jason ByrnesWebAssist

If you look at the code for an insert, you will see that the redirect URL is created before the record has been inserted. It cant use the ID of the record that will be inserted in the redirect, because that value cannot be know yet, it can only be known after the record inserts.

If you look further down the code, you will see this line after the code to perform the insert:

php:
$_SESSION[$WA_sessionName] = mysql_insert_id();



This code stores the inserted records ID into a session variable.

further up the code, you will see a line that sets the $WA_sessionName variable, it will look something like:

php:
$WA_sessionName = "WADA_Insert_visitors";



this sets the name that will be used for the session:

php:
$_SESSION['WADA_Insert_visitors']



if you want to go directly to the update page from the insert, you will need to leave the redirect in the insert behavior blank, then add code after the insert to perform the redirect using the newly created session variable in the URL.

Add this code just after the insert record behavior.

php:
<?php 
if($_SERVER['REQUEST_METHOD'] == "POST") {
    
header("Location: ads_Update.php?id_ad=".$_SESSION[$WA_sessionName]);
}
?>
Sign in to reply to this post

anthony399409

That worked perfectly! I was trying to write that, but was unsure about the $_SESSION part of it.

One day I'll know php much better.

Sign in to reply to this post

anthony399409

I was wondering if I needed URL parameters in the $WA_redirectURL function?

Sign in to reply to this post

Jason ByrnesWebAssist

no, you wont be able to use the $WA_redirectURL since this is set before the record is inserted.


you need to leave that blank, then do the redirect manually after the record is inserted to be able to use the session.

keep in mind PHP is executed from top to bottom.

where the $WA_redirectURL is set before the code to insert the record, the session does not exist when it gets set, it only exists after the record is inserted.

Sign in to reply to this post

anthony399409

Not sure what I've done, but it was working fine yesterday and now it isn't.

I'm attaching the insert file so you can see the code.

Attached Files
ads_Insert.php.zip
Sign in to reply to this post
loading

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