|
Posted by ianbarton on 10/02/73 11:58
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 <email@yourbusiness.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.htm" webpage.
<?
# Adam Internet PHP Form Mailer v1.3
# By John Edwards, Copyright September 2005.
# Mail all variables to:
$to='email@yourbusiness.com.au'; ###I have inserted my email address
here ####
$domain = 'yourbusiness.com.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(strtolower($_SERVER['HTTP_USER_AGENT']),'mozilla') # If the
user agent contains mozilla
&& strstr($_SERVER['HTTP_REFERER'], $domain) # If the referrer is us
&& !strstr($formmessage,"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 <email@yourbusiness.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_FORWARDED_FOR)
{
$header .= "X-Originating-IP: $HTTP_X_FORWARDED_FOR via
$REMOTE_ADDR\n";
}
else
{
$header .= "X-Originating-IP: $REMOTE_ADDR\n";
}
mail($to,"Web Form Details",$formmessage,$header);
header("Location: confirm.htm"); ## I have inserted the full URL for my
confirm page here ##
?>
Navigation:
[Reply to this message]
|