473,727 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Feedback Email setup

Hello all

I am trying to setup a feedback form on my webpage using some script
provided by my ISP. I really don't know a lot about PHP and it's syntax
etc.

The feedback form only has 4 fields. These are UserName, UserEmail,
UserCountry & Comments. It works well with all of those fields
appearing in the body of an email that is sent to me. What I would now
like is for the UserEmail field to appear in the "From:" field in the
header rather than only in the body of the email.

There is a line in the script that says:-
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;

I suspect I need to somehow place the UserEmail string in here somehow
but I don't know how to do it. Is it possible to do what I want?

Here is the script of the formmail.php file I am using. I have inserted
my email address at the point where it says to and I have created a
"confirm.ht m" webpage.

<?
# Adam Internet PHP Form Mailer v1.3
# By John Edwards, Copyright September 2005.
# Mail all variables to:

$to='em***@your business.com.au '; ###I have inserted my email address
here ####
$domain = 'yourbusiness.c om.au'; ### I don't have a business domain
name ####

while(list($key ,$val) = each($HTTP_POST _VARS))
{

$val = str_replace(chr (10),"",$val);
$val = str_replace(chr (13),"",$val);
$formmessage .= "$key = $val\n";
}

if(

$formmessage # If we have content
&& 'POST' == $_SERVER['REQUEST_METHOD '] # If the message is being
posted
&& strstr(strtolow er($_SERVER['HTTP_USER_AGEN T']),'mozilla') # If the
user agent contains mozilla
&& strstr($_SERVER['HTTP_REFERER'], $domain) # If the referrer is us
&& !strstr($formme ssage,"Content-Type") # Don't send XSS attempt
)
{

# Message is ok!
}
else
{

die("This request looked like a XSS attempt. Stopped");
}

# Reset the From: address for a neater look
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;
# If there's an email element, use it for reply-to
if ($email)
{

$header .= "Reply-To: $email\n";
}

# Log the IP Address of the sender.
if($HTTP_X_FORW ARDED_FOR)
{

$header .= "X-Originating-IP: $HTTP_X_FORWARD ED_FOR via
$REMOTE_ADDR\n" ;
}
else
{

$header .= "X-Originating-IP: $REMOTE_ADDR\n" ;
}

mail($to,"Web Form Details",$formm essage,$header) ;
header("Locatio n: confirm.htm"); ## I have inserted the full URL for my
confirm page here ##

?>

Sep 18 '06 #1
4 2225
ia*******@adam. com.au wrote:
Hello all

I am trying to setup a feedback form on my webpage using some script
provided by my ISP. I really don't know a lot about PHP and it's syntax
etc.

The feedback form only has 4 fields. These are UserName, UserEmail,
UserCountry & Comments. It works well with all of those fields
appearing in the body of an email that is sent to me. What I would now
like is for the UserEmail field to appear in the "From:" field in the
header rather than only in the body of the email.

There is a line in the script that says:-
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;

I suspect I need to somehow place the UserEmail string in here somehow
but I don't know how to do it. Is it possible to do what I want?
No, you want to put there the from address.
Since this script automatically sends the email, you'll have to tell it what
the from-field is.
Most probably you can put in there any valid emailaddress you own, like:
in**@adam.com

>
Here is the script of the formmail.php file I am using. I have inserted
my email address at the point where it says to and I have created a
"confirm.ht m" webpage.

<?
# Adam Internet PHP Form Mailer v1.3
# By John Edwards, Copyright September 2005.
# Mail all variables to:

$to='em***@your business.com.au '; ###I have inserted my email address
here ####
$domain = 'yourbusiness.c om.au'; ### I don't have a business domain
name ####
Use the one of your ISP.
For example, if you host your site at: www.xs4all.nl/~adam you are in domain
x4all.nl, or maybe www.xs4all.nl
>
while(list($key ,$val) = each($HTTP_POST _VARS))
{

$val = str_replace(chr (10),"",$val);
$val = str_replace(chr (13),"",$val);
$formmessage .= "$key = $val\n";
}
This part cleans up some header-injection hackattack.
It also removes any newlines from the content of the mail.

>
if(

$formmessage # If we have content
&& 'POST' == $_SERVER['REQUEST_METHOD '] # If the message is being
posted
&& strstr(strtolow er($_SERVER['HTTP_USER_AGEN T']),'mozilla') # If the
user agent contains mozilla
&& strstr($_SERVER['HTTP_REFERER'], $domain) # If the referrer is us
&& !strstr($formme ssage,"Content-Type") # Don't send XSS attempt
)

This is a really old and bad piece of code.
It uses $formmessage and I expect that it is NOT filled before like:
$formmessage = $_POST["formmessag e"];

If you are new to PHP, this is difficult to explain.
I just say it is old and will not work on a modern PHP install.

{

# Message is ok!
}
else
{

die("This request looked like a XSS attempt. Stopped");
}

# Reset the From: address for a neater look
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;
# If there's an email element, use it for reply-to
if ($email)
{

$header .= "Reply-To: $email\n";
}

# Log the IP Address of the sender.
if($HTTP_X_FORW ARDED_FOR)
{

$header .= "X-Originating-IP: $HTTP_X_FORWARD ED_FOR via
$REMOTE_ADDR\n" ;
}
else
{

$header .= "X-Originating-IP: $REMOTE_ADDR\n" ;
}

mail($to,"Web Form Details",$formm essage,$header) ;
That is the actual mailfunction.
Go to www.php.net and look up mail for more information.
header("Locatio n: confirm.htm"); ## I have inserted the full URL for my
confirm page here ##

?>

I don't like the script at all. It is probably published years ago.
Just go to www.php.net and look up the mail function.

Regards,
Erwin Moller
Sep 18 '06 #2
Thanks Erwin for your reply.

I know nothing about PHP but since I started this exercise I have
become a little, just a little more familiar with this particular
function. Unfortunately I wouldn't know enuff to know whether it is
good or bad code so I will have to take your word for that.

In your reply you state "No, you want to put there the from address.
Since this script automatically sends the email, you'll have to tell it
what the from-field is. Most probably you can put in there any valid
emailaddress you own, like: in**@adam.com"

The email address that I want to put in there is that which is supplied
in the feedback form field I have titled "UserEmail" The trouble is I
don't know what the syntax is to do this. I have tried many variations
(eg)

$header .= "From: Web Form <UserEmail>\n ";
$header .= "From: <UserEmail>\n ";
$header .= "From: 'UserEmai'l>\n" ;
$header .= "From: <$UserEmail>\n" ;
$header .= "From: $UserEmail\n";

Am I trying to do something that just isn't possible in PHP. I have
done this in ASP on another webpage but I can't get it to work here.

Regards

Erwin Moller wrote:
ia*******@adam. com.au wrote:
Hello all

I am trying to setup a feedback form on my webpage using some script
provided by my ISP. I really don't know a lot about PHP and it's syntax
etc.

The feedback form only has 4 fields. These are UserName, UserEmail,
UserCountry & Comments. It works well with all of those fields
appearing in the body of an email that is sent to me. What I would now
like is for the UserEmail field to appear in the "From:" field in the
header rather than only in the body of the email.

There is a line in the script that says:-
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;

I suspect I need to somehow place the UserEmail string in here somehow
but I don't know how to do it. Is it possible to do what I want?

No, you want to put there the from address.
Since this script automatically sends the email, you'll have to tell it what
the from-field is.
Most probably you can put in there any valid emailaddress you own, like:
in**@adam.com


Here is the script of the formmail.php file I am using. I have inserted
my email address at the point where it says to and I have created a
"confirm.ht m" webpage.

<?
# Adam Internet PHP Form Mailer v1.3
# By John Edwards, Copyright September 2005.
# Mail all variables to:

$to='em***@your business.com.au '; ###I have inserted my email address
here ####
$domain = 'yourbusiness.c om.au'; ### I don't have a business domain
name ####

Use the one of your ISP.
For example, if you host your site at: www.xs4all.nl/~adam you are in domain
x4all.nl, or maybe www.xs4all.nl

while(list($key ,$val) = each($HTTP_POST _VARS))
{

$val = str_replace(chr (10),"",$val);
$val = str_replace(chr (13),"",$val);
$formmessage .= "$key = $val\n";
}

This part cleans up some header-injection hackattack.
It also removes any newlines from the content of the mail.


if(

$formmessage # If we have content
&& 'POST' == $_SERVER['REQUEST_METHOD '] # If the message is being
posted
&& strstr(strtolow er($_SERVER['HTTP_USER_AGEN T']),'mozilla') # If the
user agent contains mozilla
&& strstr($_SERVER['HTTP_REFERER'], $domain) # If the referrer is us
&& !strstr($formme ssage,"Content-Type") # Don't send XSS attempt
)


This is a really old and bad piece of code.
It uses $formmessage and I expect that it is NOT filled before like:
$formmessage = $_POST["formmessag e"];

If you are new to PHP, this is difficult to explain.
I just say it is old and will not work on a modern PHP install.

{

# Message is ok!
}
else
{

die("This request looked like a XSS attempt. Stopped");
}

# Reset the From: address for a neater look
$header .= "From: Web Form <em***@yourbusi ness.com.au>\n" ;
# If there's an email element, use it for reply-to
if ($email)
{

$header .= "Reply-To: $email\n";
}

# Log the IP Address of the sender.
if($HTTP_X_FORW ARDED_FOR)
{

$header .= "X-Originating-IP: $HTTP_X_FORWARD ED_FOR via
$REMOTE_ADDR\n" ;
}
else
{

$header .= "X-Originating-IP: $REMOTE_ADDR\n" ;
}

mail($to,"Web Form Details",$formm essage,$header) ;

That is the actual mailfunction.
Go to www.php.net and look up mail for more information.
header("Locatio n: confirm.htm"); ## I have inserted the full URL for my
confirm page here ##

?>


I don't like the script at all. It is probably published years ago.
Just go to www.php.net and look up the mail function.

Regards,
Erwin Moller
Sep 19 '06 #3
ia*******@adam. com.au wrote:
Thanks Erwin for your reply.

I know nothing about PHP but since I started this exercise I have
become a little, just a little more familiar with this particular
function. Unfortunately I wouldn't know enuff to know whether it is
good or bad code so I will have to take your word for that.

In your reply you state "No, you want to put there the from address.
Since this script automatically sends the email, you'll have to tell it
what the from-field is. Most probably you can put in there any valid
emailaddress you own, like: in**@adam.com"

The email address that I want to put in there is that which is supplied
in the feedback form field I have titled "UserEmail" The trouble is I
don't know what the syntax is to do this. I have tried many variations
(eg)

$header .= "From: Web Form <UserEmail>\n ";
$header .= "From: <UserEmail>\n ";
$header .= "From: 'UserEmai'l>\n" ;
$header .= "From: <$UserEmail>\n" ;
$header .= "From: $UserEmail\n";

Am I trying to do something that just isn't possible in PHP. I have
done this in ASP on another webpage but I can't get it to work here.
Probably

$_REQUEST['UserEmail']

(or $_GET or $_POST instead of $_REQUEST if you know which HTTP method
is being used. But $_REQUEST will do for either.)

Colin
Sep 23 '06 #4
I finally got this all sorted out and it works fine. I have even gone
one step more and generate 2 emails, one to myself and another back to
the person who sent the feedback, providing they provide a valid email
address. This second part isn't necessary but I was "on a roll" so kept
going.

Here is my "contact.ph p" script. Remember that it has to be mentioned
in the Feedback form with a line
<form method="post" action="contact .php">

Thanks to all those who offered some assistance.
Ian

<?php
// Website Contact Form Generator

// get posted data into local variables ready for email to Ian
$EmailFrom = Trim(stripslash es($_POST['UserEmail']));
$Country = Trim(stripslash es($_POST['UserCountry']));
$EmailTo = "my own email address";
$Subject = "Web Site Feedback";
$Name = Trim(stripslash es($_POST['UserName']));
$Comments = Trim(stripslash es($_POST['Comments']));

// validation
// not used as my Form has it's own validation
//$validationOK=t rue;
//if (Trim($EmailFro m)=="") $validationOK=f alse;
//if (Trim($Country) =="") $validationOK=f alse;
//if (Trim($Name)==" ") $validationOK=f alse;
// if (Trim($Telephon e)=="") $validationOK=f alse;
// if (Trim($Email)== "") $validationOK=f alse;
//if (Trim($Comments )=="") $validationOK=f alse;
//if (!$validationOK ) {
// print "<meta http-equiv=\"refresh \" content=\"0;URL =index.htm\">";
// exit;
//}

// prepare email body text to Ian
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $EmailFrom;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";

// send email to Ian
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>" );

// get posted data into local variables ready for email to User
$EmailFrom = "";
$EmailTo = Trim(stripslash es($_POST['UserEmail']));
$Subject = "Web Site Feedback Comments";
$Comments = Trim(stripslash es($_POST['Comments']));

// prepare email body text to User
$Body = "";
$Body .= "Hello ";
$Body .= $Name;
$Body .= "\n";
$Body .= "\n";
$Body .= "Here is a copy of the Comments you sent to Ian's Website";
$Body .= "\n";
$Body .= "\n";
$Body .= "Comments: ";
$Body .= "\n";
$Body .= $Comments;
$Body .= "\n";

// send email to User
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>" );

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh \" content=\"0;URL =confirm.htm\"> ";
}
else{
print "<meta http-equiv=\"refresh \" content=\"0;URL =error.htm\">";
}
?>

Colin Fine wrote:
ia*******@adam. com.au wrote:
Thanks Erwin for your reply.

I know nothing about PHP but since I started this exercise I have
become a little, just a little more familiar with this particular
function. Unfortunately I wouldn't know enuff to know whether it is
good or bad code so I will have to take your word for that.

In your reply you state "No, you want to put there the from address.
Since this script automatically sends the email, you'll have to tell it
what the from-field is. Most probably you can put in there any valid
emailaddress you own, like: in**@adam.com"

The email address that I want to put in there is that which is supplied
in the feedback form field I have titled "UserEmail" The trouble is I
don't know what the syntax is to do this. I have tried many variations
(eg)

$header .= "From: Web Form <UserEmail>\n ";
$header .= "From: <UserEmail>\n ";
$header .= "From: 'UserEmai'l>\n" ;
$header .= "From: <$UserEmail>\n" ;
$header .= "From: $UserEmail\n";

Am I trying to do something that just isn't possible in PHP. I have
done this in ASP on another webpage but I can't get it to work here.
Probably

$_REQUEST['UserEmail']

(or $_GET or $_POST instead of $_REQUEST if you know which HTTP method
is being used. But $_REQUEST will do for either.)

Colin
Sep 26 '06 #5

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

Similar topics

5
5110
by: Andrew | last post by:
Where can i find a free feedback form in php script to download it and put it in my website? thanks in advance andreas
21
2483
by: Raymond Hettinger | last post by:
I've gotten lots of feedback on the itertools module but have not heard a peep about the new sets module. * Are you overjoyed/outraged by the choice of | and & as set operators (instead of + and *)? * Is the support for sets of sets necessary for your work and, if so, then is the implementation sufficiently powerful?
2
5224
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
1
4171
by: Norman Fritag | last post by:
Hi there I have avoided to use active x controls because I thought they are causing more problems then they are doing any good. I a new application I would want to use the tree and list view control in access 2002. Prior to that I like to fine some information or here some feed back from developers who have use active x controls success fully in there application, what their experience was.
4
1237
by: windandwaves | last post by:
Hi Folk Can you have a look at www.lakebrunner.co.nz/_n/ and tell me what you think? It is my latest creation. I am not responsible for the design so dont worry about that (font-sizes, colours, etc... unless you think it is terrible). I am responsible for the technical side of things, the navigation, etc... I am really trying to make it top class. If anyone is interested in how I structured the PHP then let me know.
9
2503
by: gs | last post by:
the feedback for the install of c#2008 places 97 to 99% cpu load for way too long on athlon x64 3800+ PC. 3/4 an hour later its only about 80% complete, continuing with 98% CPU load! Next time installing visual studio /dot product I will likely make sure no feedback
15
2642
by: nickyspace | last post by:
i have a code wherein it is asking email id and message from the user in the form named as feedback.html HTML CODE AS BELOW<html> <body> <form method="post" action="sendmail.php"> Email: <input name="email" type="text" size="20" /><br /> Message:<br /> <textarea name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" /> </form>
0
933
by: Marcus.CM | last post by:
Hi, After some debugging, i found the solution is to :- import email import email.mime.text import email.iterators import email.generator import email.utils
3
1508
by: David Thielen | last post by:
Hi all; Since everyone here is great about feedback - what do you think of this design for an XPath wizard? This is for people who span the gamut from barely know what an XML file is to programmers. http://www.windwardreports.com/mktg/Videos/AutoTag7_XpathWizard/First_Peek_Xpath_Wizard.html thanks - dave
0
8890
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
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9402
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8101
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
6702
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
6011
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
4521
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
4785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.