/    Sign up×
Community /Pin to ProfileBookmark

Cookie redirection issue after submit (form)

I have an issue with a redirect I am trying to add on a website. I am not a big expert so that’s why I am asking for kind help.

Before showing the code here are the issues, and how I wanted this to work.

So, I have an Aweber form added to my site with two fields Name and Email + the submit button. Basically, if a submission is successful the user would be redirected to another page and a cookie would set in.

What’s with the cookie?

Well the form is on **website.com**, and if a user gets subscribed he is redirected **website.com/whatever.html**

Also, if he subscribed, the next time he enters **website.com** he will be automatically redirected on **website.com/whatever.html**

Ok, so I got this main idea to work but I have an issue with it working correctly.

Basically, now it redirects the user even if he enters incorrect details, like Name: JHKJHKhj and Email: jkhkjhkjhkhjk

If he enters these details like that (incorrectly) he should get on the error page which is set by Aweber, but now he gets redirected anyways.

So this is how this should work :

  • 1.

    User enters details properly, he gets redirected and cookie sets in.


  • 2.

    User enters details incorrectly, he gets the default Aweber error page and he is not redirected.

    [CODE]> $(document).ready(function() {
    > $(‘#subscribe1’).show()
    >
    > if (!readCookie(‘hide’)) {
    > }
    >
    > else {
    > window.location = “http://website/whatever”
    > }
    >
    >
    > $(‘#sendbtn’).click(function() {
    > window.location = “http://website/whatever”
    > createCookie(‘hide’, true, 365)
    > return false;
    > });
    >
    > });
    >
    >
    >
    > function createCookie(name,value,days) {
    > if (days) {
    > var date = new Date();
    > date.setTime(date.getTime()+(days*24*60*60*1000));
    > var expires = “; expires=”+date.toGMTString();
    > }
    > else var expires = “”;
    > document.cookie = name+”=”+value+expires+”; path=/”;
    > }
    >
    > function readCookie(name) {
    > var nameEQ = name + “=”;
    > var ca = document.cookie.split(‘;’);
    > for(var i=0;i < ca.length;i++) {
    > var c = ca[i];
    > while (c.charAt(0)==’ ‘) c = c.substring(1,c.length);
    > if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    > }
    > return null;
    > }
    >
    > function eraseCookie(name) {
    > createCookie(name,””,-1);
    > }[/CODE]

  • [code=html]<form method=”post” class=”af-form-wrapper” action=”http://www.aweber.com/scripts/addlead.pl” >
    <div style=”display: none;”>
    <input type=”hidden” name=”meta_web_form_id” value=”522321120″ />
    <input type=”hidden” name=”meta_split_id” value=”” />
    <input type=”hidden” name=”listname” value=”jenselter” />
    <input type=”hidden” name=”redirect” value=”http://www.aweber.com/thankyou-coi.htm?m=text” id=”redirect_9fdb1fef967f03c9b582bc463f43b007″ />

    <input type=”hidden” name=”meta_adtracking” value=”My_Web_Form” />
    <input type=”hidden” name=”meta_message” value=”1″ />
    <input type=”hidden” name=”meta_required” value=”name,email” />

    <input type=”hidden” name=”meta_tooltip” value=”” />
    </div>
    <div id=”af-form-522321120″ class=”af-form”><div id=”af-header-522321120″ class=”af-header”><div class=”bodyText”><p>&nbsp;</p></div></div>
    <div id=”af-body-522321120″ class=”af-body af-standards”>
    <div class=”af-element”>
    <label class=”previewLabel” for=”awf_field-54960658″>Name: </label>
    <div class=”af-textWrap”>
    <input id=”awf_field-54960658″ type=”text” name=”name” class=”text” value=”” tabindex=”500″ />
    </div>
    <div class=”af-clear”></div></div>
    <div class=”af-element”>
    <label class=”previewLabel” for=”awf_field-54960659″>Email: </label>
    <div class=”af-textWrap”><input class=”text” id=”awf_field-54960659″ type=”text” name=”email” value=”” tabindex=”501″ />
    </div><div class=”af-clear”></div>
    </div>
    <div class=”af-element buttonContainer”>
    <input name=”submit” id=”af-submit-image-522321120″ type=”image” class=”image” style=”background: none;” alt=”Submit Form” src=”http://www.aweber.com/images/forms/marla/submit.png” tabindex=”502″ />
    <div class=”af-clear”></div>
    </div>
    <div class=”af-element privacyPolicy” style=”text-align: center”><p>We respect your <a title=”Privacy Policy” href=”http://www.aweber.com/permission.htm” target=”_blank”>email privacy</a></p>
    <div class=”af-clear”></div>
    </div>
    <div class=”af-element poweredBy” style=”text-align: center; font-size: 9px;”><p>Powered by AWeber <a href=”http://www.aweber.com” title=”Email Marketing Tools”>Email Marketing Tools</a></p>
    <div class=”af-clear”></div>
    </div>
    </div>
    <div id=”af-footer-522321120″ class=”af-footer”><div class=”bodyText”><p>&nbsp;</p></div></div>
    </div>
    <div style=”display: none;”><img src=”http://forms.aweber.com/form/displays.htm?id=rExMzEyMjEwM” alt=”” /></div>
    </form>[/code]

    Would be great if you could help me…

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @brkdj spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...