Newbe Question
am 17.11.2007 17:19:41 von Sam Bench
I am very new to php and know virtually nothing about it. I want to do a
very simple task:
I have a form that generates 5 outputs: $name, $email, $number,and $mission,
$type. I want to have a .php file email these 5 outputs to a certain email
address. I am close to figuring out how to do this. I have setup a .php
file as follows:
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
$number = stripslashes($number);
$mission= stripslashes($mission);
$type=stripslashes($type);
$strsub="Poinsettia Order";
$mail_body=$name+$email+$mission+$type+$number;
mail('joesmith@comsat.com', $strsub,$mail_body, "From: $name <$email>");
echo("Thank you for your poinsettia order. Your order was sent to the admin
in charge.");
?>
I have uploaded the .html form and the above .php file to my server. When I
run the form, I almost get what I want. When I hit send on the form I get
an email sent to me. It has $strsub as the subject. It has $name
<$email>in the From field. However, in the body of the email I don't get
all the form information that I want. In fact, the above code just sends me
$number. The rest of the form info is missing. How can I fix the code so
that all 5 fields that I want appear in the body of the email that gets sent
to me?
Thanks in advance.
Re: Newbe Question
am 17.11.2007 17:31:06 von Norman Peelman
Sam Bench wrote:
> I am very new to php and know virtually nothing about it. I want to do a
> very simple task:
>
> I have a form that generates 5 outputs: $name, $email, $number,and $mission,
> $type. I want to have a .php file email these 5 outputs to a certain email
> address. I am close to figuring out how to do this. I have setup a .php
> file as follows:
>
>
> @extract($_POST);
> $name = stripslashes($name);
> $email = stripslashes($email);
> $number = stripslashes($number);
> $mission= stripslashes($mission);
> $type=stripslashes($type);
> $strsub="Poinsettia Order";
> $mail_body=$name+$email+$mission+$type+$number;
> mail('joesmith@comsat.com', $strsub,$mail_body, "From: $name <$email>");
> echo("Thank you for your poinsettia order. Your order was sent to the admin
> in charge.");
> ?>
>
> I have uploaded the .html form and the above .php file to my server. When I
> run the form, I almost get what I want. When I hit send on the form I get
> an email sent to me. It has $strsub as the subject. It has $name
> <$email>in the From field. However, in the body of the email I don't get
> all the form information that I want. In fact, the above code just sends me
> $number. The rest of the form info is missing. How can I fix the code so
> that all 5 fields that I want appear in the body of the email that gets sent
> to me?
>
> Thanks in advance.
>
>
$mail_body=$name.$email.$mission.$type.$number;
Norm
Re: Newbe Question
am 17.11.2007 17:33:22 von Steve
"Sam Bench" wrote in message
news:OuWdnQ-z09hfiaLanZ2dnUVZ_oKhnZ2d@comcast.com...
>I am very new to php and know virtually nothing about it. I want to do a
>very simple task:
>
> I have a form that generates 5 outputs: $name, $email, $number,and
> $mission, $type. I want to have a .php file email these 5 outputs to a
> certain email address. I am close to figuring out how to do this. I have
> setup a .php file as follows:
>
>
> @extract($_POST);
> $name = stripslashes($name);
> $email = stripslashes($email);
> $number = stripslashes($number);
> $mission= stripslashes($mission);
> $type=stripslashes($type);
> $strsub="Poinsettia Order";
> $mail_body=$name+$email+$mission+$type+$number;
this is not VB or javascript. php uses a dot/period (.) to concatenate
strings. the above should result in $mail_body being a number.
> mail('joesmith@comsat.com', $strsub,$mail_body, "From: $name <$email>");
> echo("Thank you for your poinsettia order. Your order was sent to the
> admin in charge.");
> ?>
i assume this is just a test email, as the above would result in a pretty
ugly email.
> I have uploaded the .html form and the above .php file to my server. When
> I run the form, I almost get what I want. When I hit send on the form I
> get an email sent to me. It has $strsub as the subject. It has $name
> <$email>in the From field. However, in the body of the email I don't get
> all the form information that I want. In fact, the above code just sends
> me $number.
hmmmm...i wonder why that is...oh yeah, see first comment.
> The rest of the form info is missing. How can I fix the code so that all
> 5 fields that I want appear in the body of the email that gets sent to me?
>
> Thanks in advance.
>
Re: Newbe Question
am 17.11.2007 19:08:20 von Jerry Stuckle
Sam Bench wrote:
> I am very new to php and know virtually nothing about it. I want to do a
> very simple task:
>
> I have a form that generates 5 outputs: $name, $email, $number,and $mission,
> $type. I want to have a .php file email these 5 outputs to a certain email
> address. I am close to figuring out how to do this. I have setup a .php
> file as follows:
>
>
> @extract($_POST);
> $name = stripslashes($name);
> $email = stripslashes($email);
> $number = stripslashes($number);
> $mission= stripslashes($mission);
> $type=stripslashes($type);
> $strsub="Poinsettia Order";
> $mail_body=$name+$email+$mission+$type+$number;
> mail('joesmith@comsat.com', $strsub,$mail_body, "From: $name <$email>");
> echo("Thank you for your poinsettia order. Your order was sent to the admin
> in charge.");
> ?>
>
> I have uploaded the .html form and the above .php file to my server. When I
> run the form, I almost get what I want. When I hit send on the form I get
> an email sent to me. It has $strsub as the subject. It has $name
> <$email>in the From field. However, in the body of the email I don't get
> all the form information that I want. In fact, the above code just sends me
> $number. The rest of the form info is missing. How can I fix the code so
> that all 5 fields that I want appear in the body of the email that gets sent
> to me?
>
> Thanks in advance.
>
>
>
In addition to what the others said - "From: $name <$email>" is very
insecure. It can open your server to spammers. At the very least strop
out any newline characters in it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================