Skip navigation
Currently Being Moderated

On a form w Validation, how to redirect to a custom page

Sep 24, 2012 11:39 AM

Tags: #cs5 #spry_validate #spry_form #dreamweaver_form

Hi. I have created a form in Dreamweaver CS5 that uses spry validation successfully. Once the form is submitted, the user is redirected to the home page. But I don't want that redirect.

 

My question is, how can I have the validated page redirect to a custom thank you page I designed? I don't know the exact code/syntax to write to make it do what I want and, even if I had the code, I wouldn't know exactly where it should be placed. Please help if you can. Here's the source code. )BTW, when I use Dreamweaver Behaviors to add a URL redirect, it ignores the required validation and simply allows you to click the submit button and redirect.) Many thanks!

 

<!DOCTYPE HTML>

<html>

<head>

<meta charset="UTF-8">

<link href="../_css/main.css" rel="stylesheet" media="screen, projection">

<link href="../_css/forms.css" rel="stylesheet" media="screen, projection">

 

<title></title>

<!--[if lt IE 9]>

<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script><![endif]-->

 

<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">

<script type="text/javascript">

 

<!-- **** I think the line of code for the redirect is here??...I just don't know how to write the code to redirect to the page I want ***** -->

function MM_goToURL() { //v3.0

  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;

  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");

}

</script>

</head>

 

<body>

<header id="pageHeader">

<a href="../index.htm"><img src="../_images/logo.gif" width="170" height="91" alt="HMN logo" id="logo"></a>

<img src="../_images/tagline.png" width="296" height="92" alt="HMN tagline" id="tagline">

 

</header>

 

<nav id="mainNav">

<ul>

<li><a href="../index.htm">Home</a></li>

<li><a href="../press.htm">Press</a></li>

<li><a href="../about.htm">About</a></li>

<li><a href="../contact.htm">Contact</a></li>

</ul>

</nav>

 

<br class="clear">

 

<div class="headerContact">

</div>

 

<article>

  <!-- The file webformmailer.php sits on the web server at godaddy.com in case that matters -->

 

<section id="Request">

<p id="intro">To request your link for the downloadable <span id="highlight">Media Kit</span>, please provide the following information:</p>

<form name="Request" method="post" action="../../webformmailer.php"> <p id="formCaption">Fields marked with * are required.</p>

  <p><span id="sprytextfield1">

    <label for="first_name">First Name:*</label>

    <input type="text" name="first_name" id="first_name">

    <span class="textfieldRequiredMsg">(required)</span></span></p>

  <p><span id="sprytextfield2">

    <label for="last_name">Last Name:*</label>

    <input type="text" name="last_name" id="last_name">

    <span class="textfieldRequiredMsg">(required)</span></span></p>

  <p><span id="sprytextfield3">

    <label for="company">Company:*</label>

    <input type="text" name="company" id="company">

    <span class="textfieldRequiredMsg">(required)</span></span></p>

  <p>

    <label for="address">Address:</label>

    <input type="text" name="address" id="address">

  </p>

  <p>

    <label for="address_2">Address 2:</label>

    <input type="text" name="address_2" id="address_2">

  </p>

  <p>

    <label for="city">City:</label>

    <input type="text" name="city" id="city">

  </p>

  <p>

    <label for="state">State:</label>

    <input type="text" name="state" id="state">

  </p>

  <p>

    <label for="zip">Zip:</label>

    <input type="text" name="zip" id="zip">

  </p>

  <p><span id="sprytextfield4">

  <label for="email">Email:*</label>

  <input type="text" name="email" id="email">

  <span class="textfieldRequiredMsg">(required)</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> </p>

  <p>

  <input name="submit" type="image" id="submit" onClick="MM_goToURL('parent','media_kit_download.htm');return document.MM_returnValue" src="../_images/btn_submit.png">

  </p>

  <p> </p>

 

</form>

<p>

</p>

</div>

</div>

 

</section>

</article>

 

<script type="text/javascript">

var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur"]});

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur"]});

var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur"]});

var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "email", {validateOn:["blur"]});

</script>

</body>

</html>

 
Replies
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 24, 2012 10:21 PM   in reply to catstalker

    What you have quoted is a function MM_goToURL that is being called on submission.

    function MM_goToURL() { //v3.0

     

    In your form below, you'll see where MM_goToURL takes the user on submission. I've highlighted this URL.

     

      <input name="submit" type="image" id="submit" onClick="MM_goToURL('parent','media_kit_download.htm');return document.MM_returnValue" src="../_images/btn_submit.png">

    I'm assuming this is the page the contact form is on by itself. Change the bold URL above to whatever custom page you want the user to see when they submit the form.

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Sep 25, 2012 5:23 AM   in reply to catstalker

    Can you post a link to your webpage for us to check?

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2012 5:37 AM   in reply to catstalker

    You could try changing this:

     

     

    if ($landing_page != "") {

            header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");

    }

    else {

            header("Location: http://".$_SERVER["HTTP_HOST"]."/");

    }

     

     

    to: (thankyou.html is a custom page you can set up)

     

    if ($landing_page != "") {

            header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");

    }

    else {

            header("Location: http://www.yourDomain.com/thankyou.html");

    }

     

     

     

    OR try the other way around if the above doesn't work. I don't know what the $landing_page variable is refering to:

     

    if ($landing_page != "") {

            header("Location: http://www.yourDomain.com/thankyou.html");

    }

    else {

            header("Location: http://".$_SERVER["HTTP_HOST"]."/");

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2012 7:40 AM   in reply to catstalker

    catstalker wrote:

     

    I do still have an issue however. I have two fill-in forms with validation on the website. I can use the solution you've provided to redirect Form #1. How do I redirect Form#2 to a thankyou#2.htm page?

     

     

     

    Now that's a question I don't have an answer for. If you have two forms it may be better to put the 'redirect' in the webformmailer.php file. Can you show me what is in that? Then you can send one form to webformmailer_1.php and the other to webformmailer_2.php for processing

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 25, 2012 8:18 AM   in reply to catstalker

    catstalker wrote:

     

     

     

     

    Oh, that's actually what I did...put the redirect in the  webformmailer.php file. The file, in its entirety, is copied above in my post of 5:17am. I just replaced the bit at the end as you'd suggested.

     

    Then you can send one form to webformmailer_1.php and the other to webformmailer_2.php for processing

    I did exactly that and it worked! Which is great.

     

     

     

    Yeah, sorry I provided the solution and then forgot lol!

    catstalker wrote:

     

     

    My only concern  is that, since  webformmailer.php  is a file written and maintained by GoDaddy, if they make changes to it or how their servers respond to it, I may have issues.  Does that seem unlikely? Am I overthinking this?

     

     

    It's highly unlikely that they would make changes to the servers that would stop the php script running on their servers. The php just looks to me like standard php, nothing particularly associated specifically with GoDaddy.

     

    Well its good to overthink because that will eliminate a lot of issues!

     

    I think your safe.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points