PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > Newbe Question
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Newbe Question

Réponse
 
LinkBack Outils de la discussion
Vieux 17/11/2007, 16h19   #1
Sam Bench
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbe Question

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:

<?php
@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.


  Réponse avec citation
Vieux 17/11/2007, 16h31   #2
Norman Peelman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbe Question

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:
>
> <?php
> @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
  Réponse avec citation
Vieux 17/11/2007, 16h33   #3
Steve
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbe Question


"Sam Bench" <roykoch@comcast.net> 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:
>
> <?php
> @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.
>



  Réponse avec citation
Vieux 17/11/2007, 18h08   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbe Question

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:
>
> <?php
> @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
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h44.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12708 seconds with 12 queries