/    Sign up×
Community /Pin to ProfileBookmark

Popup "Thank you for contacting" window instead of redirect to page

I have a pretty simple form-to-email contact form on my page (you can see it [URL=”http://bscphoto.com/testing/weddings/request_quote.html”]here [/URL]) Right now it has the generic thank you page and i have the option to redirecting to another page.. but i hate it.

So what i was HOPING was to just have a quick little popup that says “thanks for contacting” and they can close it or choose to go back to another page from there.

Or isntead of a popup window, it can clear out all of the form and just display a thankyou page.

Anyways.. here is my email form code:

[QUOTE]

<?php

error_reporting(E_ALL ^ E_NOTICE);

/*

Thank you for choosing FormToEmail by FormToEmail.com

Version 2.5 April 16th 2009

COPYRIGHT FormToEmail.com 2003 – 2009

You are not permitted to sell this script, but you can use it, copy it or distribute it, providing that you do not delete this copyright notice, and you do not remove any reference or links to FormToEmail.com

For support, please visit: [url]http://formtoemail.com/support/[/url]

*/

$my_email = “[email protected]“;

/*

Optional. Enter a From: email address. Only do this if you know you need to. By default, the email you get from the script will show the visitor’s email address as the From: address. In most cases this is desirable. On the majority of setups this won’t be a problem but a minority of hosts insist that the From: address must be from a domain on the server. For example, if you have the domain example.com hosted on your server, then the From: email address must be [email][email protected][/email] (See your host for confirmation). This means that your visitor’s email address will not show as the From: address, and if you hit “Reply” to the email from the script, you will not be replying to your visitor. You can get around this by hard-coding a From: address into the script using the configuration option below. Enabling this option means that the visitor’s email address goes into a Reply-To: header, which means you can hit “Reply” to respond to the visitor in the conventional way. (You can also use this option if your form does not collect an email address from the visitor, such as a survey, for example, and a From: address is required by your email server.) The default value is: $from_email = “”; Enter the desired email address between the quotes, like this example: $from_email = “[email protected]“; In these cases, it is not uncommon for the From: ($from_email) address to be the same as the To: ($my_email) address, which on the face of it appears somewhat goofy, but that’s what some hosts require.

*/

/* $from_email = “”; */

/*

Optional. Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage.

If you do change it, remove the “/” symbol below and replace with the name of the page to link to, eg: “mypage.htm” or “http://www.elsewhere.com/page.htm

*/

$continue = “/”;

/*

Step 3:

Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT – The file name is case sensitive! You must save it exactly as it is named above!

THAT’S IT, FINISHED!

You do not need to make any changes below this line.

*/

$errors = array();

// Remove $_COOKIE elements from $_REQUEST.

if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}

// Validate email field.

if(isset($_REQUEST[’email’]) && !empty($_REQUEST[’email’]))
{

$_REQUEST[’email’] = trim($_REQUEST[’email’]);

if(substr_count($_REQUEST[’email’],”@”) != 1 || stristr($_REQUEST[’email’],” “)){$errors[] = “Email address is invalid”;}else{$exploded_email = explode(“@”,$_REQUEST[’email’]);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = “Email address is invalid”;}else{if(substr_count($exploded_email[1],”.”) == 0){$errors[] = “Email address is invalid”;}else{$exploded_domain = explode(“.”,$exploded_email[1]);if(in_array(“”,$exploded_domain)){$errors[] = “Email address is invalid”;}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match(‘/^[a-z0-9-]+$/i’,$value)){$errors[] = “Email address is invalid”; break;}}}}}}

}

// Check referrer is from same site.

if(!(isset($_SERVER[‘HTTP_REFERER’]) && !empty($_SERVER[‘HTTP_REFERER’]) && stristr($_SERVER[‘HTTP_REFERER’],$_SERVER[‘HTTP_HOST’]))){$errors[] = “You must enable referrer logging to use the form”;}

// Check for a blank form.

function recursive_array_check_blank($element_value)
{

global $set;

if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
else
{

foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}

}

}

recursive_array_check_blank($_REQUEST);

if(!$set){$errors[] = “You cannot send a blank form”;}

unset($set);

// Display any errors and exit if errors exist.

if(count($errors)){foreach($errors as $value){print “$value<br>”;} exit;}

if(!defined(“PHP_EOL”)){define(“PHP_EOL”, strtoupper(substr(PHP_OS,0,3) == “WIN”) ? “rn” : “n”);}

// Build message.

function build_message($request_input){if(!isset($message_output)){$message_output =””;}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace(“_”,” “,ucfirst($key)).”: “.build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).”, “;}}}}return rtrim($message_output,”, “);}

$message = build_message($_REQUEST);

$message = $message . PHP_EOL.PHP_EOL.”– “.PHP_EOL.”Thank you for using FormToEmail from http://FormToEmail.com“;

$message = stripslashes($message);

$subject = “FormToEmail Comments”;

$subject = stripslashes($subject);

if($from_email)
{

$headers = “From: ” . $from_email;
$headers .= PHP_EOL;
$headers .= “Reply-To: ” . $_REQUEST[’email’];

}
else
{

$from_name = “”;

if(isset($_REQUEST[‘name’]) && !empty($_REQUEST[‘name’])){$from_name = stripslashes($_REQUEST[‘name’]);}

$headers = “From: {$from_name} <{$_REQUEST[’email’]}>”;

}

mail($my_email,$subject,$message,$headers);

?>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<html>

<head>
<title>Form To Email PHP script from FormToEmail.com</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body bgcolor=”#ffffff” text=”#000000″>

<div>
<center>
<b>Thank you <?php if(isset($_REQUEST[‘name’])){print stripslashes($_REQUEST[‘name’]);} ?></b>
<br>Your message has been sent
<p><a href=”<?php print $continue; ?>”>Click here to continue</a></p>
<p><b>FormToEmail</b> by <a href=”http://FormToEmail.com”>FormToEmail.com</a></p>
</center>
</div>

</body>
</html>

[/QUOTE]

If you can point me to any type of tutorial or ANYTHING, i would really appreciate it. I am learning quickly, but this is something that Id on’t even really know where to start. I have no done much with pop up windows to tell you the truth

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@lindsayanngauthorDec 16.2009 — ok.. I tried this and it worked as a pop up when tested just using the dreamweaver preview in browser, but when the actual PHP is being used on my test server, it completely ignores the pop up and posts to the thankyou default page:

[code=html]<form method="post" action="../FormToEmail.php" enctype="multipart/form-data" accept-charset="UTF-8" target="windowName" onsubmit="window.open('', this.target,
'dialog,modal,scrollbars=no,resizable=no,width=550,height=300,left=0,top=0');">[/code]
Copy linkTweet thisAlerts:
@FangDec 16.2009 — So what i was HOPING was to just have a quick little popup that says "thanks for contacting" and they can close it or choose to go back to another page from there.[/QUOTE][URL="http://www.tizag.com/javascriptT/javascriptconfirm.php"]confirm

[/URL]

Or isntead of a popup window, it can clear out all of the form and just display a thankyou page.[/QUOTE]Ask on the PHP form, this is quite simple.
Copy linkTweet thisAlerts:
@lindsayanngauthorDec 16.2009 — I didn't want a "are you sure you want to do this" box.. I would like a "Thank you.. your message has been set" box

That means that clicking the submit button will send the mail with no need for another confirmation. It will send the email and then a pop up will appear saying "thanks for your message' and the form will clear.

like i said, I am pretty new to this side of things (i do generally front end stuff) so a little more help is appreciated. Wheny ou say "ask on the php form" you really aren'y helping much. I know i need to ask it to do something by writing the code.. i'm unsure as to how to get there, as I said previously.
Copy linkTweet thisAlerts:
@criterion9Dec 16.2009 — I believe what Fang was saying is that this has been posted to the javascript forum where people may or may not know much PHP if any at all so you would be more likely to get assistance by posting this on the PHP forum as what you are asking for should be altered in the PHP code and not with Javascript.
Copy linkTweet thisAlerts:
@lindsayanngauthorDec 16.2009 — Read again.. i dont think that is what he was saying.. None the less, i can ask there. I figured that calling a popup window would within the relhhms of javascript.. I mean, i guess this could be posted on either forum.
Copy linkTweet thisAlerts:
@criterion9Dec 17.2009 — 
Ask on the PHP form, this is quite simple.[/QUOTE]

Was attached to where you had:

Or isntead of a popup window, it can clear out all of the form and just display a thankyou page. [/quote]

Either solution will require a slight alteration to the PHP code however. The javascript portion is easily done using:
window.alert("Thank you for your comments.");
Copy linkTweet thisAlerts:
@lindsayanngauthorDec 17.2009 — Yes, i understand how to make a simple pop up, but i guess i need to figure out how to make it work when you use the submit button.
Copy linkTweet thisAlerts:
@FangDec 17.2009 — &lt;form action="foo.php" method="" name="form1" onsubmit="alert('thank you'); return true;"&gt;
Copy linkTweet thisAlerts:
@lindsayanngauthorDec 17.2009 — I did try something like that (look at th second post in this thread) and it popped up a window, but didn't submit the form
Copy linkTweet thisAlerts:
@FangDec 17.2009 — You opened a new window, not a modal window
×

Success!

Help @lindsayanng 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...