473,804 Members | 3,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

if (!strstr($_SERV ER['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 1512
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_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

if (!strstr($_SERV ER['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(..yourstuf fhere..);

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

echo (($mailresult) ? "SUCCES!":"PROB LEM 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_rep lace("\n","<br> ",$_SESSION['sentmessage']);
echo($OutPut);

"Joker7" wrote in message news:<7F******* ********@fe101. usenetserver.co m>...
>
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_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

if (!strstr($_SERV ER['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_rep lace("\n","<br> ",$_SESSION['sentmessage']);
echo($OutPut);

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

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_referr er = getenv( "HTTP_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

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

}

$messageprop er =

"This message was sent from:\n" .
"$http_referre r\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*******@attgl obal.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*******@attg lobal.netwrote in message
news:g6******** **@registered.m otzarella.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_re place("\n","<br >",$_SESSION['sentmessage']);
echo($OutPut );

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

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" ;
$thankyouur l = "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_referre r = getenv( "HTTP_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

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

}

$messageprope r =

"This message was sent from:\n" .
"$http_referr er\n" .
"------------------------------------------------------------\n" .
"Name of sender: $name\n" .
"Email of sender: $email\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailt o, $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*******@attgl obal.net
=============== ===

Jul 22 '08 #5
Tim McGurk wrote:
"Jerry Stuckle" <js*******@attg lobal.netwrote in message
news:g6******** **@registered.m otzarella.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_r eplace("\n","<b r>",$_SESSION['sentmessage']);
echo($OutPut) ;

"Joker7" wrote in message
news:<7F***** **********@fe10 1.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" ;
$thankyouu rl = "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_referr er = getenv( "HTTP_REFER ER" );

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_quot es_gpc()) {
$comments = stripslashes( $comments );
}

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

}

$messageprop er =

"This message was sent from:\n" .
"$http_refer rer\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*******@attgl obal.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*******@attgl obal.net
=============== ===
Jul 25 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3800
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 file: <?php /* recipients */ $to = "valid@email.add" . ", " ; // note the comma $to .= $_POST;
2
5226
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 running IIS on my home machine. My problem is that I need to upload this stuff to a webhosting place and register a domain and I'm not sure what to put as the smtp mail server value
5
2478
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 are sometime NULL. Using the desktop integration package we have which interfaces with MS Word when printing an address in a letter the end results often end up looking like this. 1 Any Street AnyTown
8
5484
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
23
2811
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 place a link on there site so people can vote for their program, "ad a click". eg someone clicks the link on some page and it counts +1 click on my page. if some one clicks the link below it will count a click on my page.
4
1966
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 never comes, so i need your help with me, and here is my script: mail.htm code: <form method="POST" action="mail.php" onSubmit="">
11
26647
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 and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
5
2308
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 email. however all the information is missing form the email I only get the first form text field?? #!/bin/perl # ------------------------------------------------------------
1
3886
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. This works great with one attachment. I am requiring that a file be attach before submitting. Now I am trying to add the ability to add multiple attachments and I am able to create this however, it will error out if all of the attachment is not...
2
234
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 data transfer using encryption techniques. Objectives can be summarized as: • Designing and implementing server applications • Designing and implementing client applications • Encrypting and decrypting o Use of DES, RSA o Use of hash...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.