Click to See Complete Forum and Search --> : Last Ditch Effort with Mailto Form
whathedilly45
09-08-2007, 02:02 PM
Hello. Forgive me if you've seen my posts on this matter that were similar. I'm basically at my wit's end with a mailto form. I'm an ienxperienced designer working on a site for a friend. The site can be seen at: www.brendapogge.com/beta. If you look at the upper right you'll see the form that I attempted to create. I just need a really really simple form that I put inside a table that will fit nicely and will submit the information in the text box to a specific email address. I know absolutely nothing about php coding, or about server side script. Can someone dumb this down for me as much as humanly possible? Thanks for being patient with me. :)
kiwibrit
09-08-2007, 03:12 PM
Here's a video. (http://www.thesitewizard.com/general/feedback-form-video.shtml)
whathedilly45
09-10-2007, 09:23 PM
Thanks for the link kiwibrit. It seemed simple enough. I just finished creating my page, and uploaded it. I'm frustrated because it still doesn't seem to work. Here is the code for the actual page:
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>:: Brenda Pogge for Delegate! ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
/****************************************************
****************************************************/
function init() {
if (!document.getElementById) return
var imgOriginSrc;
var imgTemp = new Array();
var imgarr = document.getElementsByTagName('img');
for (var i = 0; i < imgarr.length; i++) {
if (imgarr[i].getAttribute('hsrc')) {
imgTemp[i] = new Image();
imgTemp[i].src = imgarr[i].getAttribute('hsrc');
imgarr[i].onmouseover = function() {
imgOriginSrc = this.getAttribute('src');
this.setAttribute('src',this.getAttribute('hsrc'))
}
imgarr[i].onmouseout = function() {
this.setAttribute('src',imgOriginSrc)
}
}
}
}
onload=init;
</script>
<STYLE type="text/css"><!--
A:link{color:#0C68F3;text-decoration:none;}
A:active{color:#0C68F3;text-decoration:none;}
A:visited{color:#0C68F3;text-decoration:none;}
A:hover{color:gray;text-decoration:none;}
--></STYLE>
<link href="textbox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFFF" background="poggebg3.jpg" leftmargin="0" topmargin="0" marginheight="0" margintop="0">
<table width="100%" align="center" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="150" height="292" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center">
<p><font color="#000000" size="2" face="Tahoma"><strong>To contact
Brenda by mail, send your letters to:</strong></font></p>
<p><font color="#003399" size="2" face="Century Gothic"><strong>Brenda
Pogge for Delegate <br>
P.O. Box 1386 <br>
Yorktown, VA 23692 <br>
Phone: 757-223-9690 </strong><br>
</font></p>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center"><font color="#000000"><strong><font size="2" face="Tahoma">If
you would like to email Brenda:</font><br>
<font face="Century Gothic"></font></strong></font></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><form action="http://brendapogge.com/beta/feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr>
<td>Name:</td>
<td><input type="text" name="name" size="25" /></td>
</tr>
<tr>
<td>Email address:</td>
<td><input type="text" name="email" size="25" /></td>
</tr>
<tr>
<td colspan="2"> Comments<br /> <textarea rows="15" cols="45" name="comments"></textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2"> <input type="submit" value="Send Feedback" />
<br /> </td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>"
Here is a copy of the .php file I used (which is uploaded to the same directory as the page:
"<?
/*
CHFEEDBACK.PHP Feedback Form PHP Script Ver 2.07
Generated by thesitewizard.com's Feedback Form Wizard.
Copyright 2000-2006 by Christopher Heng. All rights reserved.
thesitewizard and thefreecountry are trademarks of Christopher Heng.
$Id: phpscript.txt,v 1.8 2006/02/28 13:07:11 developer Exp $
Get the latest version, free, from:
http://www.thesitewizard.com/wizards/feedbackform.shtml
You can read the Frequently Asked Questions (FAQ) at:
http://www.thesitewizard.com/wizards/faq.shtml
I can be contacted at:
http://www.thesitewizard.com/feedback.php
Note that I do not normally respond to questions that have
already been answered in the FAQ, so *please* read the FAQ.
LICENCE TERMS
1. You may use this script on your website, with or
without modifications, free of charge.
2. You may NOT distribute or republish this script,
whether modified or not. The script can only be
distributed by the author, Christopher Heng.
3. THE SCRIPT AND ITS DOCUMENTATION ARE PROVIDED
"AS IS", WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
IMPLIED WARRANTY OF MECHANTABILITY OR FITNESS FOR A
PARTICULAR PURPOSE. YOU AGREE TO BEAR ALL RISKS AND
LIABILITIES ARISING FROM THE USE OF THE SCRIPT,
ITS DOCUMENTATION AND THE INFORMATION PROVIDED BY THE
SCRIPTS AND THE DOCUMENTATION.
If you cannot agree to any of the above conditions, you
may not use the script.
Although it is NOT required, I would be most grateful
if you could also link to thesitewizard.com at:
http://www.thesitewizard.com/
*/
// ------------- CONFIGURABLE SECTION ------------------------
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto = "youremailaddress@example.com" ;
$mailto = 'kevinrhaggerty@yahoo.com' ;
// $subject - set to the Subject line of the email, eg
//$subject = "Feedback Form" ;
$subject = "Feedback Form" ;
// the pages to be displayed, eg
//$formurl = "http://www.example.com/contactframe.htm" ;
//$errorurl = "http://www.example.com/error.htm" ;
//$thankyouurl = "http://www.example.com/thankyou.htm" ;
$formurl = "http://www.brendapogge.com/beta/contactframe.htm" ;
$errorurl = "http://www.brendapogge.com/beta/error" ;
$thankyouurl = "http://www.brendapogge.com/beta/thankyou.htm" ;
$uself = 0;
// -------------------- END OF CONFIGURABLE SECTION ---------------
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
header( "Location: $errorurl" );
exit ;
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper,
"From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" );
header( "Location: $thankyouurl" );
exit ;
?>"
You can see the final product at: www.brendapogge.com/beta/contact.htm.
When I type content and then hit the submit button, I get no email. Please help!
whathedilly45
09-13-2007, 12:41 AM
bump?
NogDog
09-13-2007, 04:59 AM
Try changing "<?" to "<?php" in case your web host has short_open_tags turned off (which is really the preferred mode these days, anyway).
kiwibrit
09-13-2007, 05:35 AM
I'm sorry I don't have the time to do a line by line check.
One thought occurs: keep things simple to start off with. Work out a simple form which has no javascript. Then use javascript for from validation prior to actual submission server side. Then add any more javascript bells and whistles after that.
NogDog
09-13-2007, 05:47 AM
Note that JavaScript validation will do nothing to stop bad data from malicious users as well as users who have JS turned off for any reason. The JS validation is a convenience to the user, but you must still validate the inputs on the server side.
Also, the mail script you are using is susceptible to hijacking by malicious users who could use it to send spam via header injections through the $email value being used in the headers argument to mail().
Lastly, most servers will probably reject your mail() command's call to the host's sendmail program, as you are using the user's email for the "From:" header. Most hosts will require that the "From:" header be a valid email address on that host, i.e. it won't relay mail from other hosts.
whathedilly45
09-15-2007, 02:29 PM
Hey guys. I didn't write the script. I took kiwi's advice and went to thesitewizard.com. I followed their step-by-step instructions and used their feedback form wizard. After all that, it doesn't work. I don't know much about javascript. I don't know hardly anything about server-side script or any of that. I just need a really simple form that will send its content to an email address, and I need it to work. I don't need it to be beautiful, I just need it to work. Can somebody please just give me something that is easy to do?
Thanks!
~Kevin
NogDog
09-16-2007, 04:47 AM
If your host supports PHP:
<?php
###############################################################################
#
# mail.php - general-purpose email form and script
#
# created by Charles Reace (www.charles-reace.com)
#
# This software is freeware. You may use it or modify it however you want.
# It comes with no guarantees or warranties, explicit or implicit.
#
###############################################################################
###############################################################################
# user-defined variables - update for your email address(es)
###############################################################################
# link to "thank you" page:
$thanks = "http://www.example.com.com/success.php";
# email address for the "From:" header (usually must be a valid address
# on the sending server:
$from = "johdoe@example.com";
# Modify the following variables to set up where emails will be sent.
$to = "johndoe@example.com";
# uncomment and edit the next line if you want to cc someone:
# $cc = "ccname@example.com";
# uncomment and edit the next two line if you want to bcc someone:
# $bcc = "bccname@example.com";
#################################
# end of user-defined variables #
#################################
# email address validation function
# kudos to http://iamcal.com/publish/articles/php/parsing_email/
function is_valid_email_address($email) {
$qtext = '[^\\x0d\\x22\\x5c\\xa6-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\xa6-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\xa6-\\xff]+';
$quoted_pair = '\\x5c[\\x00-\\xa5]';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return (preg_match("!^$addr_spec$!", $email));
}
# Init. some variables:
$error = "";
$success = FALSE;
# process form if submitted:
if(isset($_POST['submit']))
{
foreach($_POST as $key => $val)
{
if(empty($_POST[$key]))
{
$error .= "You must enter a value for " .
ucwords(str_replace("_"," ",$key)) . ". ";
}
else
{
if(get_magic_quotes_gpc())
{
$_POST[$key] = stripslashes($val);
}
}
if($key != 'message')
{
$_POST[$key] = preg_replace('/[\r\n]+/', ' ', $val);
}
}
if($_POST['email_address'] != $_POST['repeat_email'])
{
$error .= "Email Address is not the same as Repeat Email. ";
}
elseif(is_valid_email_address($_POST['email_address']) == 0)
{
$error .= "'{$_POST['email_address']}' does not appear to be a valid email address. ";
}
if(empty($error)) # no errors in input, so go ahead and email it.
{
$headers = "From: $from";
if(!empty($cc))
{
$headers .= "\r\nCc: $cc";
}
if(!empty($bcc))
{
$headers .= "\r\nBcc: $bcc";
}
$headers .= "\r\nX-Mailer: PHP/" . phpversion();
$msg = "From {$_POST['name']} ({$_POST['email_address']})";
$msg .= "\n\n\n{$_POST['message']}";
$result = @mail($to,
$_POST['subject'],
$msg,
$headers);
if(!$result)
{
$error = "There was an unknown error while attempting to send your email.";
}
else
{
header("Location: $thanks");
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>
<title>Email Me</title>
<style type="text/css">
<!--
-->
</style>
</head>
<body>
<?php
if(!empty($error))
{
echo "<p style='color: #c03;'>$error</p>\n";
}
?>
<h2>Email Me</h2>
<form action='<?php echo $_SERVER['PHP_SELF'] ?>' method=post>
<fieldset>
<legend>Your Contact Information</legend>
<p><label for='name' style="display: block; float: left; width: 9em;">Name:</label>
<input type='text' name='name' id='name' size='30' maxlength='40'<?php
if(!empty($_POST['name']))
{
echo "value='{$_POST['name']}'";
}
?>></p>
<p><label for='email_address' style="display: block; float: left; width: 9em;">Email Address:</label>
<input type='text' name='email_address' id='email_address' size='30' maxlength='40'<?php
if(!empty($_POST['email_address']))
{
echo "value='{$_POST['email_address']}'";
}
?>></p>
<p><label for='repeat_email' style="display: block; float: left; width: 9em;">Repeat Email:</label>
<input type='text' name='repeat_email' id='repeat_email' size='30' maxlength='40'<?php
if(!empty($_POST['repeat_email']))
{
echo "value='{$_POST['repeat_email']}'";
}
?>></p>
</fieldset>
<fieldset>
<legend>Message</legend>
<p><label for='subject' style="display: block; float: left; width: 9em;">Subject:</label>
<input type='text' name='subject' id='subject' size='50' maxlength='60'<?php
if(!empty($_POST['subject']))
{
echo " value='{$_POST['subject']}'";
}
?>></p>
<p><label for='message'>Message:</label><br>
<textarea name='message' id='message' cols='50' rows='8'
style="width: 375px"><?php
if(!empty($_POST['message']))
{
echo $_POST['message'];
}
?></textarea></p>
</fieldset>
<p style="text-align: center;"><input type='submit' name='submit' value="Send Email"></p>
</form>
</body>
</html>