This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > August 2004 > php form





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author php form
Neil McDermott

2004-08-26, 12:20 pm

Hi everyone,

I have just installed a PHP form on my website to gather data from a form
and post it to my email address. I got the script from a free PHP resource
and I have very little PHP coding experience myself.

The problem is when I receive the data in Outlook express the address is
from anonymous. Is there anyway in which I can get the customers email
address to appear in the "from" section of the email I receive? The PHP
script is below.

<?
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$organisation=$_POST['organisation'];
$address=$_POST['address'];
$city=$_POST['city'];
$postcode=$_POST['postcode'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$where=$_POST['where'];
$comments=$_POST['comments'];
$to="postmaster@myaddress.com";
$from="$email";
$message="$firstname\n
$lastname\n
$email\n
$organisation\n
$address\n
$city\n
$postcode\n
$phone\n
$where\n
$comments";
if(mail($to,"Customer Information","$message\n"))
{$URL="http://www.myaddress.com/thankyou.htm";header ("Location: $URL");
} else {
echo "There was a problem sending the mail. Please check that you filled in
the form correctly.";
}
?>



Thank in advance for any help.

Neil
www.easiserv.com



Michael Fesser

2004-08-26, 12:20 pm

.oO(Neil McDermott)

>The problem is when I receive the data in Outlook express the address is
>from anonymous. Is there anyway in which I can get the customers email
>address to appear in the "from" section of the email I receive? The PHP
>script is below.
>
><?


Change this line to

<?php

>if(mail($to,"Customer Information","$message\n"))


if (mail($to, "Customer Information", "$message\n", "From: $from"))

HTH
Micha
Peter Connolly

2004-08-26, 12:20 pm

Neil McDermott wrote:
> Hi everyone,
>
> I have just installed a PHP form on my website to gather data from a
> form and post it to my email address. I got the script from a free
> PHP resource and I have very little PHP coding experience myself.
>
> The problem is when I receive the data in Outlook express the address
> is from anonymous. Is there anyway in which I can get the customers
> email address to appear in the "from" section of the email I receive?
> The PHP script is below.
>
> <?
> $firstname=$_POST['firstname'];
> $lastname=$_POST['lastname'];
> $organisation=$_POST['organisation'];
> $address=$_POST['address'];
> $city=$_POST['city'];
> $postcode=$_POST['postcode'];
> $phone=$_POST['phone'];
> $email=$_POST['email'];
> $where=$_POST['where'];
> $comments=$_POST['comments'];
> $to="postmaster@myaddress.com";
> $from="$email";
> $message="$firstname\n
> $lastname\n
> $email\n
> $organisation\n
> $address\n
> $city\n
> $postcode\n
> $phone\n
> $where\n
> $comments";
> if(mail($to,"Customer Information","$message\n"))
> {$URL="http://www.myaddress.com/thankyou.htm";header ("Location:
> $URL"); } else {
> echo "There was a problem sending the mail. Please check that you
> filled in the form correctly.";
> }



Try

if(mail($to,"Customer Information","$message\n","From: ".$email))

See also http://uk2.php.net/manual/en/function.mail.php

HTH,

Pete.
--
Peter Connolly
http://www.acutecomputing.co.uk
Derby
UK


Neil McDermott

2004-08-26, 12:21 pm

Wow!

Thanks everyone. That problem has been doing my head in for weeks and
you've solved it in a couple of hours!

Thanks again,

Neil
www.easiserv.com


"Michael Fesser" <netizen@gmx.net> wrote in message
news:mitoi0d7bnje5lr44uo5qvrhp21hrujivd@4ax.com...
> .oO(Neil McDermott)
>
>
> Change this line to
>
> <?php
>
>
> if (mail($to, "Customer Information", "$message\n", "From: $from"))
>
> HTH
> Micha



Sponsored Links


Copyright 2003 - 2009 forum4designers.com  Software forum  Computer Hardware reviews