Forum Moderators: coopster

Message Too Old, No Replies

PHP popups needed

"Thank You" popup needed after submission

         

doodlebee

4:16 pm on Sep 8, 2005 (gmt 0)

10+ Year Member


I have a newsletter sign-up thing for a client. Basically, it's a small e-mail form embedded in a major content page, in the sidebar. The client wants for the end user to just be reading the page, and if they decide to sign up for the newsletter, they can just enter in their e-mail address and..the end.

I have no problem getting it set up so that they can e-mail and subit their address...my issue is this:

the client *does not* want the end user to leave the page they're on. They want the person to submit the e-mail address, have a popup window that says "Thanks!", and have the user return to the same page they were at, with the form cleared.

I'm having sever issues trying to find how this works. I can make a popup on submit - but it returns to a blank page when you close the window. If I try to make it so it returns to the current page on window close, the e-mail is still in the form - and if I try to set it to clear, no email comes through.

Could anyone help me out on this? Thanks in advance :[smilestopper])

BananaFish

5:06 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



open the popup with javascript to a page that processes the address. eg this js code in your form:

onSubmit="popWin('thanks.php?email='+ escape(this.email.value));return false;"

where popWin is a js function that opens the popup and email is the name of the email text box. The email address will be $_GET variable in the page you pop.

BananaFish

5:14 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Add this code before the "return false;" in the javascript to clear the form - "this.email.text='';"

BananaFish

5:14 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



actually it should be "this.email.value='';"

doodlebee

1:00 am on Sep 9, 2005 (gmt 0)

10+ Year Member



Thanks Bananafish...

However, I tried it, but it was a no-go. I did find an alternate solution that doesn't use popups at all. Hopefully the client will be happy with that! But I do appreciate the attempt :)

StupidScript

11:34 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The popup will definitely be a client-side solution, like Javascript. If they really want one, that's what you'll need to use.

You could simply (a) accept the form submission, and (b) return to the original page (default values) and (c) trigger the Javascript popup if the data is validated.

i.e.
(included in form.php)

<form action="<?=$_SERVER["SCRIPT_NAME"]?>" method=post>

<input type="hidden" name="dopop" value=1 />

 ... the rest of the form ...

then when the form is submitted, it posts the data back to the server, and returns to the same page, i.e.
(also included in form.php):

<?

if ($_POST["dopop"]) {

... validate and process form data ...

}

?>

and, if the form validates:

<? if ($validated) {?>

<script type="text/javascript">

...popup code...

</script>

<? }?>

If the form data validates, the form page will be returned to its default values, the form data will have been processed, and Javascript will pop up the "thanks" window for a successful submission.

If the form data does not validate, you can stop the process right there and re-populate the form with the POST data along with your note about what needs to be corrected. The Javascript popup need not be triggered. The user corrects the form and re-submits, and on you go.