View Full Version : Script for 'POST e-mail' and 'thank you page'
Jonner
01-12-2007, 10:23 AM
Hi. I am pretty new to all this. I have implemented script from the following location on the dynamicdrive web site for my form. http://www.dynamicdrive.com/style/csslibrary/item/css-tableless-form/P0/
The script contains 'css style sheet' and script for my .htm page. I just need to amend the script so that when the form is submitted an e-mail of the data is sent to me and the form gets redirected to a thank you page.
Can some please help!!
Thank you
John
jscheuer1
01-12-2007, 11:18 AM
Actually, there is no script on the DD library demo page that your post links to. What the form does is determined by its action and method attributes, in the demo - action is left blank and method isn't included as its default is 'get'. This is so that whatever you like may be inserted as the action and you may change the method to post as well, if it suits you. Also having an impact on what the form can do is what you have available to you on your server or from a third party as far as mail handling goes (many third party mail handlers as well as many host provided ones are free). Ideally, to get the result that you want, you would have some sort of server-side or third party mail handling software configured for use with your mail forms. Many hosts offer formail. The instructions for its use are usually also available from the hosts that provide it or they can be found on the web in various places.
Without a web based mail handler, you could rely upon the user's mail client via scripting or simply as a mailto: reference as the action for the form but, many users do not have a mail client or, if they do it may not be configured properly for their browser or, even if they do have both of those, their javascript may not be enabled. Due to any of these possibilities, it is best to have a web based mail handler for these sorts of things.
chechu
01-12-2007, 05:40 PM
Check out this thread:
http://www.dynamicdrive.com/forums/showthread.php?t=15709
If you need it more specific, let me know.
chechu
01-12-2007, 05:46 PM
Previous link wasn't really what you're loooking for.
Copy/paste the below codes, and let me know !
PHP:
<?php
if ($_POST["action"] == "send"){
if ($_POST[name] != "your name" and $_POST[name] != "" and $_POST[email] != "your e-mail adress" and $_POST[email] != "" and $_POST[message] != "") {
mail ("me@mysite.com", "via website (EN)",
"
Name: ".$_POST['name']."
E-mail: ".$_POST['email']."
Message: ".$_POST['message']."
",
"From: ".$_POST['name']." <".$_POST['email'].">");
$subject = "your message to (your name)";
$msg = "
Dear $_POST[name],
Thanks for your message to (your name).
She will get back to you as soon as possible.
This was your message:
$_POST[message]
";
$headers = "your name";
mail($_POST[email], $subject, $msg, $headers);
echo '<p align="center"><font color="#003366">Your message has been sent, <br>and you will receive a confirmation mail. <br> We will get back to you as soon as we can.</font></p>';
}
else{
echo '<p align="center"><font color="#FF0000">Please fill in all data!<br>All fields are obligatory.</font></p><p><a href="contactENform.html">[back]</a>';
}
}
?>
HTML:
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td align="center" valign="middle" style="padding-left:210px;">
<script language="JavaScript" type="text/JavaScript">
function clearDefault(el) {
if (el.defaultValue==el.value) el.value = ""
}
</script>
<FORM NAME="form1" METHOD="post" ACTION="contactEN.php">
<input type="hidden" name="action" value="send">
<table width="100%" valign="top" align=center>
<tr><td>
<table width="160" align=left>
<tr><td width="154" height="26" align=center background="icon/form.jpg">
<INPUT TYPE=TEXT NAME="name" VALUE="your name" onFocus="clearDefault(this)" style="border:0px; width:148px">
</td></tr>
<tr><td width="154" height="26" align=center background="icon/form.jpg">
<INPUT TYPE=TEXT NAME="email" VALUE="your e-mail adress" onFocus="clearDefault(this)" style="border:0px; width:148px">
</td></tr></table>
</td><td align=left valign=middle>
<INPUT TYPE="image" src="icon/emailgo.jpg" NAME="submit" VALUE="go" style="border: 0px">
</td><td style="padding-left:20px;">
</td></tr></table>
<table width="100%" valign="top" align=center>
<tr><td width="250" height="120" align=center valign="middle" background="formbericht.jpg" class="focusareaback">
 <TEXTAREA NAME="message" style="border:0px; width:240px; height:110px"></TEXTAREA>
</td></tr></table>
</FORM>
</td></tr></table>
Note that in this script, text is already placed into the <input> fields.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.