close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Clear persistent form data on successful form submission?

Thread began 10/01/2016 5:37 pm by MagsW | Last modified 10/10/2016 5:59 pm by Ray Borduin | 98 views | 4 replies |

MagsW

Clear persistent form data on successful form submission?

I have a contact form set up in a shared file and included on multiple pages. The form includes captcha validation and I have also set up form persistence so that if they get the captcha wrong, they don't have to retype their message. However, the form data is being kept even after successful submission so the user can see it on every page the form appears on. How do I get it to clear when a successful submission is made?

Sign in to reply to this post

Ray BorduinWebAssist

It is stored in the session, so you could clear the session variable. Another option is to add a url parameter to the failed validation so that it only uses the persisted values when it fails.

Sign in to reply to this post

MagsW

Hi Ray, I tried clearing the session but it doesn't work, it's still retaining the form data after successful submission. I suspect it's something to do with the code order but I put the clear session info at line 1 which I think is the standard place? I've tried ordering the various code blocks differently but the current order ensures everything else works properly.

How would I go about using the URL parameter option? At the moment it redirects to test.php?sent=false#captchafail if it fails the captcha. I've attached a copy of the current page for info.

Sign in to reply to this post

Ray BorduinWebAssist

The actual session variable name would be "WASF_contact" if you wanted to delete it.

To only show the value after a failed validation you would use something like:

php:
<?php echo(isset($_GET['sent'])?WA_getSavedFormValue("contact","name"):""); ?>
Sign in to reply to this post

MagsW

Thanks Ray, I got it working as follows:

<?php
@session_start();
if(isset($_GET['sent']) && $_GET['sent'] == "true"){
// WA_ClearSession
$clearAll = FALSE;
$clearThese = explode(",","WASF_contact");
if($clearAll){
foreach ($_SESSION as $key => $value){
unset($_SESSION[$key]);
}
}
else{
foreach($clearThese as $value){
unset($_SESSION[$value]);
}
}
}
?>

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