473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 1496
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rainmaker | last post by:
Greetings, I have not been able to find the documentation that will allow me to insert php code inside the html code in the $message block in the mail() function. Using the example in the help...
2
by: Mindful_Spirit | last post by:
I'm trying to set up a basic email feed back form like this, and was wondering about some basic configuration settings. I have used code from this website. I have it working just fine. I'm...
5
by: David M Loraine | last post by:
I am a sql novice and would appreciate any help with the following problem. In a table I have property addresses stored in 6 fields. Field6 always hold the Post Code. However, fields 4 and 5...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
23
by: casper christensen | last post by:
Hi I run a directory, where programs are listed based on the number of clicks they have recieved. The program with most clicks are placed on top and so on. Now I would like people to be apple to...
4
by: shror | last post by:
dear all, i have started learning php 2 weeks ago and i have wrote my first script for mail sender and the script takes all my data and move to the thanks page but the problem is that the mails...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
1
by: budyerr | last post by:
All, I am trying to build a email submission form using asp.net. I currently have a web form page that will upload to my webhosting server, attach to email then delete the file after sending. ...
2
by: ahmadoubay_20240 | last post by:
The assignment aims at enforcing the encryption and communication techniques. It helps the student in acquiring the necessary knowledge in developing client/server application and in securing...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.