Enquiry form question

3 posts by 3 authors in: Forums > CMS Builder
Last Post: February 26, 2013   (RSS)

By paulmac - February 26, 2013

Hi

We have an enquiry form on our site. When a form is completed and sent, a message appears on the page to confirm this.

The code is:

$errorsAndAlerts = "Thanks for your enquiry. A representative fwill deal with your enquiry.";
$_REQUEST = array(); // clear form values

Rather than displaying the message I would like the users to be redirected to a different page and then have the message displayed there.

Can someone help me with this.

Thanks

By mizrahi - February 26, 2013

Change the <form> "action" to the address of the page you want it to redirect to.

By gregThomas - February 26, 2013

Hi,

Another way would be like this:

    redirectBrowserToURL('/newPage.php?success='.urlencode('Thanks for your enquiry. A representative will deal with your enquiry.'));
    $_REQUEST = array(); // clear form values
    exit;

So at the point when the form has been filled out correctly, you could use the CMSB function redirectBrowserToURL() to send the user to the new page, and include a variable in the URL called success with the success message in.

Then on the page the browser is redirected to:

<?php 
  if(@$_REQUEST['success']){
    echo htmlspecialchars($_REQUEST['success']);
  }
?>

So this statement checks if there is variable called success in the url, and if there is it displays its contents. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com