Redirect of form submit

6 posts by 3 authors in: Forums > CMS Builder
Last Post: December 2, 2013   (RSS)

Hi Guys,

A client once to have a a form filled in on their site, and if succesul, redirect to another page rather than:

      //
      $errorsAndAlerts = "Thank you for contacting the us. We have received your enquiry and will be in touch with you as soon as possible.";
      $_REQUEST = array(); // clear form values

They want this new page so they can add some google conversion tracking script (they've supplied)

How do I say - "If no errors, go to this page..."

Cheers,

Tim (toledoh.com.au)

done - perfect - thanks!

Cheers,

Tim (toledoh.com.au)

By Codee - December 2, 2013

Hi Dave,

Here's a follow up question. Let's say that the form has no errors, successfully submits, and then the visitor gets redirected to the correct URL...is there an easy way at this juncture to have CMSB email the administrator that a form was just submitted?

Thanks!

By Dave - December 2, 2013

Hi equinox, 

Yes, typically you'd send the email and then redirect the user and you'd do that by inserting some "send email" code right before the redirect.  Here's some example code that uses CMSB's sendMessage() function: 

$mailErrors = sendMessage(array(
  'from'    => "from@example.com",
  'to'      => "to@example.com",
  'subject' => "Enter subject here",
  'text'    => "Text message content here",
));
if ($mailErrors) { die("problem sending message: $mailErrors); }

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Codee - December 2, 2013

Outstanding!  Thank you.