|
|
|
|
Thread title: Sending form emails back to senders |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
04-15-2006, 10:09 AM
|
#1
|
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
Posts: 5,572
|
Sending form emails back to senders
Hi all,
I have had a request to send a copy of peoples enquiries back to their own email addresses through their online feedback form.
I don't know php and have been using a free form for several years for simple email forms.
I am stumped as to how to go about doing this.
This is the free form I use:
<?php
/*
################################################## ########################################
## FILE: nvform.php ##
## ##
## Novice Form Version 1.1 ##
## © Copyright 2000-2003 Seth Michael Knorr mail@sethknorr.com ##
## ##
## http://www.noviceform.com/ ##
## Please contact me with any bugs found, or any bug fixes. ##
## ##
## ##
################################################## ########################################
## ##
## There is no email support provided for this script, the only support can be ##
## found at our web site: http://www.noviceform.com/ ##
## ##
## ##
## ANY PERSON(S) MAY USE AND MODIFY THESE SCRIPT(S) FREE OF CHARGE FOR EITHER BUSINESS ##
## OR PERSONAL, HOWEVER AT ALL TIMES HEADERS AND COPYRIGHT MUST ALWAYS REMAIN IN TACT. ##
## ##
## REDISTRIBUTION FOR PROFIT IS PROHIBITED WITH OUT THE CONSENT OF SETH KNORR. ##
## ##
## By using this code you agree to indemnify Seth M. Knorr from any liability that ##
## might arise from its use. ##
## ##
## ##
################################################## ########################################
*/
/* $sendto is the email where form results are sent to */
$sendto = "info@circle.co.nz";
/* $ccto is the email where form results can be carbon copied to */
$ccto = "";
/*
O P T I O N A L V A R I A B L E S
*/
$setokurls = "0";
$okurls = "http://yourdomain.com,http://www.yourdomain.com,192.103.45.67";
/*
N O N E E D T O E D I T A N Y V A R I A B L E S B E L O W
*/
$footer = "<br><br><br><br><br><center><font face=\"Arial\"><a href=\"http://www.noviceform.com/\" target=\"_blank\"><font color=\"#ff0000\">Form processing script provided by Novice Form</font></a> </center></font>";
$backbutton = "<br><br><b>Hit your browsers back button and resubmit the form.</b>";
/* check to see if posted */
if ($HTTP_GET_VARS || ! $HTTP_POST_VARS || $_GET || ! $_POST) {
include("nverror.php");
no_pst();
}else{
/* IF OLDER VERSION OF PHP CONVERT TO NEWER VARIABLES */
if (! $_POST) {
$_POST = "$HTTP_POST_VARS";
}
if (! $_SERVER) {
$_SERVER = "$HTTP_SERVER_VARS";
}
$year = date("Y");
$month = date("m");
$day = date("d");
$hour = date("h");
$min = date("i");
$tod = date("a");
$ip=$_SERVER["REMOTE_ADDR"];
$SEND_prnt = "The form below was submited by " . $_POST{"email"} . " from Ip address: $ip on $monthnameactual $month/$day/$year at $hour:$min $tod \n";
$SEND_prnt .= "-------------------------------------------------------------------------\n\n";
/* CHECK TO SEE IF $_POST{"required"} IS SET */
if ($_POST{"required"}){
$post_required = $_POST{"required"};
$required = split(",", $post_required);
$reqnum = count($required);
for ($req=0; $req < $reqnum; $req++) {
$REQ_name = $required[$req];
$REQ_value = $POST{"$REQ_name"};
if ($REQ_name == "email") {
$goodem = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $_POST{"email"}, $trashed);
if (! $goodem) {
include("nverror.php");
msng_email();
} /* end ! $goodem */
}
elseif (! $_POST{"$REQ_name"}) {
$isreqe = "1";
$REQ_error .= "<li> $REQ_name ";
} /* end ! req val */
} /* end REQ for loop */
/* IF THERE ARE ANY REQUIRED FIELDS NOT FILLED IN */
if ($isreqe == "1") {
include("nverror.php");
msng_required();
}
} /* END CHECK TO SEE IF $_POST{"required"} IS SET */
/* END IF THERE ARE ANY REQUIRED FIELDS NOT FILLED IN */
/* GET POSTED VARIABLES */
foreach ($_POST as $NVPOST_name => $NVPOST_value) {
/* GET LEADS EMAIL */
$email_lower = strtolower($NVPOST_name);
if ($email_lower == "email") {
$SEND_email = "$NVPOST_value";
}
/* END GET LEADS EMAIL */
if (! $_POST{"sort"}) {
/* CHECK TO SEE IF CONFIG FIELD */
if ($NVPOST_name == "subject" || $NVPOST_name == "sort" || $NVPOST_name == "required" || $NVPOST_name == "success_page"){}else{
$SEND_prnt .= "$NVPOST_name: $NVPOST_value \n";
}
} /* end ! sort */
} /* end foreach */
/* END GET POSTED VARIABLES */
if ($_POST{"sort"}) {
/* SORT VARIABLES */
$sortvars = split(",", $_POST{"sort"});
$sortnum = count($sortvars);
for ($num=0; $num < $sortnum; $num++) {
$SEND_prnt .= "$sortvars[$num]: " . $_POST{"$sortvars[$num]"} . " \n";
}
} /* END SORT VARIABLES */
/* send mail */
if (! $ccto) {
$header = "From: $SEND_email\r\nReply-to: $SEND_email";
}else{
$header = "From: $SEND_email\r\nReply-to: $SEND_email\r\nCc: $ccto";
}
mail($sendto, $_POST{"subject"}, $SEND_prnt, $header);
/* END sendmail */
/* CHECK TO SEE IF FORM SPECIFYS A SUCCESS PAGE */
if (! $_POST{"success_page"}) {
include("nverror.php");
default_success();
}else{
$successpage=$_POST{"success_page"};
header("Location: $successpage"); /* redirect */
exit;
}
} /* END IF POSTED */
?>
This is the html I use to use this form:
<form method="post" action="nvform.php"><input name="subject" value="Circle Design Feedback Form" type="hidden">
<input name="success_page" value="http://www.circle.co.nz/success.html" type="hidden"><input name="required" value="sender,email,phone" type="hidden">
<p><strong>Your name:</strong> *<br />
<input name="sender" size="40" maxlength="100" type="text"><br /><br />
<strong>Your e-mail address:</strong> *<br />
<input name="email" size="40" maxlength="100" type="text"><br /><br />........
......
<input name="submit" value="Send E-mail" type="submit">
<input name="reset" value="Reset the form" type="reset">
All my form does is send the email to me, not back to the sender. Can someone please help me so I can send back to senders? Does anyone know what I am trying to ask here? and can anyone please help?
|
|
04-15-2006, 11:30 AM
|
#2
|
Status: Custom User Title
Join date: Apr 2005
Location:
Expertise:
Software:
Posts: 2,297
|
Do you want an exact copy of the email sent to you to be send back to them? If you do, then you can just add this code:
Code:
mail($_POST{"email"}, $_POST{"subject"}, $SEND_prnt, $header);
under:
Code:
mail($sendto, $_POST{"subject"}, $SEND_prnt, $header);
That will send a copy of the email, the exact email, that you get, to the email address that the user submitted into the form.
|
|
04-15-2006, 09:42 PM
|
#3
|
Status: Simply to simplify
Join date: Apr 2005
Location: Foxton, Manawatu, New Zealand
Expertise:
Software:
Posts: 5,572
|
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|