469,964 Members | 1,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Help with mail script


Hi,
I use the script below to send a email from a contact form but it would be
nice if the conformed sent page showed what was sent.Question how can I do
this ?

Thanks
Chris

<?php
$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>
Jun 2 '08 #1
5 1345
Joker7 schreef:
Hi,
I use the script below to send a email from a contact form but it would be
nice if the conformed sent page showed what was sent.Question how can I do
this ?

Thanks
Chris

<?php
$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>

Hi,

http://nl2.php.net/manual/en/function.mail.php

says for returnvalue of your mail command:
Return Values
Returns TRUE if the mail was successfully accepted for delivery, FALSE
otherwise.
It is important to note that just because the mail was accepted for
delivery, it does NOT mean the mail will actually reach the intended
destination.
So just change it in:
$mailresult = mail(..yourstuffhere..);

And then use the value for $mailresult to display if the sending was
succesful.

echo (($mailresult) ? "SUCCES!":"PROBLEM WITH SENDING" );

Regards,
Erwin Moller
Jun 2 '08 #2
The easiest way is to put it in a session variable and just echo the
session variable on the confirmation page...

//// on the form page, before the redirect
$_SESSION['sentmessage']=$messageproper;

///// on the confirmation page
$OutPut=str_replace("\n","<br>",$_SESSION['sentmessage']);
echo($OutPut);

"Joker7" wrote in message news:<7F***************@fe101.usenetserver.com>...
>
Hi,
I use the script below to send a email from a contact form but it would be
nice if the conformed sent page showed what was sent.Question how can I do
this ?

Thanks
Chris
$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>



Jul 21 '08 #3
Tim McGurk wrote:
The easiest way is to put it in a session variable and just echo the
session variable on the confirmation page...

//// on the form page, before the redirect
$_SESSION['sentmessage']=$messageproper;

///// on the confirmation page
$OutPut=str_replace("\n","<br>",$_SESSION['sentmessage']);
echo($OutPut);

"Joker7" wrote in message news:<7F***************@fe101.usenetserver.com>...
>>

Hi,
I use the script below to send a email from a contact form but it would be
nice if the conformed sent page showed what was sent.Question how can I do
this ?

Thanks
Chris
>>$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>


Please learn to reply to the original message, instead of starting a new
thread.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 21 '08 #4
I did reply; I didn't start a new thread. The original message is an old
one, but he hadn't gotten an answer. Load the messages from May or
thereabouts, and the original message will appear in the list rather than my
reply.

But thanks for the concern!

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:g6**********@registered.motzarella.org...
Tim McGurk wrote:
> The easiest way is to put it in a session variable and just echo the
session variable on the confirmation page...

//// on the form page, before the redirect
$_SESSION['sentmessage']=$messageproper;

///// on the confirmation page
$OutPut=str_replace("\n","<br>",$_SESSION['sentmessage']);
echo($OutPut);

"Joker7" wrote in message
news:<7F***************@fe101.usenetserver.com>.. .
>>>

Hi,
I use the script below to send a email from a contact form but it would
be
nice if the conformed sent page showed what was sent.Question how can I
do
this ?

Thanks
Chris

$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>



Please learn to reply to the original message, instead of starting a new
thread.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 22 '08 #5
Tim McGurk wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:g6**********@registered.motzarella.org...
>Tim McGurk wrote:
>> The easiest way is to put it in a session variable and just echo the
session variable on the confirmation page...

//// on the form page, before the redirect
$_SESSION['sentmessage']=$messageproper;

///// on the confirmation page
$OutPut=str_replace("\n","<br>",$_SESSION['sentmessage']);
echo($OutPut);

"Joker7" wrote in message
news:<7F***************@fe101.usenetserver.com>. ..

Hi,
I use the script below to send a email from a contact form but it would
be
nice if the conformed sent page showed what was sent.Question how can I
do
this ?

Thanks
Chris

$mailto = 'e****@mail.co' ;
$subject = "Feedback Form" ;
$formurl = "http://page.co/ of form" ;
$errorurl = "http://page.co/contact.php" ;
$thankyouurl = "http://page.co/thankyou.php" ;
$uself = 1;
$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 );
}

if (!strstr($_SERVER['HTTP_REFERER'], 'page.co')) { exit ("Invalid
referrer");

}

$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: Feed Back" );
header( "Location: $thankyouurl" );
exit ;

?>


Please learn to reply to the original message, instead of starting a new
thread.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


I did reply; I didn't start a new thread. The original message is an old
one, but he hadn't gotten an answer. Load the messages from May or
thereabouts, and the original message will appear in the list rather
than my
reply.

But thanks for the concern!
(Top posting fixed)

Sorry - I checked two different news servers, and the original message
wasn't on either one. I did check your headers, but didn't see the
message you were supposedly referencing, either.

Guess it was just too old for the servers. Sorry.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 25 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Rainmaker | last post: by
5 posts views Thread by David M Loraine | last post: by
23 posts views Thread by casper christensen | last post: by
4 posts views Thread by shror | last post: by
11 posts views Thread by cybervigilante | last post: by
1 post views Thread by budyerr | last post: by
2 posts views Thread by ahmadoubay_20240 | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.