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.comp.lang.php > Form emails
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Form emails

Réponse
 
LinkBack Outils de la discussion
Vieux 02/07/2007, 14h47   #1
Geoff
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Form emails

I want to create an on-line form & into one of the text boxes the visitor
will enter his email address. So far so good. However, when that form is
emailed to me, I want that email address to appear in the "From" field of
the email. I know this cannot be done in HTML because the variable cannot
be transferred across pages, but can it be done in PHP? Or is there
another way of achieving it?

Any advice much appreciated and if there are any sample scripts anywhere,
even more appreciated.

Geoff


  Réponse avec citation
Vieux 02/07/2007, 19h38   #2
Brendan Gillatt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Form emails

On Mon, 2 Jul 2007 14:47:42 +0100, "Geoff" <someone@home.uk> wrote:

>I want to create an on-line form & into one of the text boxes the visitor
>will enter his email address. So far so good. However, when that form is
>emailed to me, I want that email address to appear in the "From" field of
>the email. I know this cannot be done in HTML because the variable cannot
>be transferred across pages, but can it be done in PHP? Or is there
>another way of achieving it?
>
>Any advice much appreciated and if there are any sample scripts anywhere,
>even more appreciated.
>
>Geoff
>


$from = $_POST['emailaddress'];

$to = 'someemail@aol.com';

$subject = $_POST['subject'];

mail($to, $subject, $msg, "From: $from\n");
--
Brendan Gillatt
www.brendangillatt.co.uk
GPG: 0x6E265E61
  Réponse avec citation
Vieux 03/07/2007, 00h28   #3
Alexander Schestag
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Form emails

Hi,

Brendan Gillatt wrote:
> On Mon, 2 Jul 2007 14:47:42 +0100, "Geoff" <someone@home.uk> wrote:
>
>> I want to create an on-line form & into one of the text boxes the visitor
>> will enter his email address. So far so good. However, when that form is
>> emailed to me, I want that email address to appear in the "From" field of
>> the email. I know this cannot be done in HTML because the variable cannot
>> be transferred across pages, but can it be done in PHP? Or is there
>> another way of achieving it?
>>
>> Any advice much appreciated and if there are any sample scripts anywhere,
>> even more appreciated.


> $from = $_POST['emailaddress'];
>
> $to = 'someemail@aol.com';
>
> $subject = $_POST['subject'];
>
> mail($to, $subject, $msg, "From: $from\n");


Never, never, never ever do it this way without any proper input
validation! Using $_POST is not enough to validate the values coming
from a form. You should never trust them!

For example, $name should at least be validated this way:

$val = array(
'/^[0-9a-zA-Z]+$/',
);

$subject='default';

if (isset($_POST['subject'])) {
foreach ($val as $k => $v) {
if (preg_match($v, $_POST['subject'])) {
$subject = $_POST['subject']));
break;
}
}

Of course, you can define more allowed signs in the array $val. But
then, further input validation might be necessary.

Alex
  Réponse avec citation
Vieux 03/07/2007, 00h39   #4
Alexander Schestag
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Form emails

Alexander Schestag wrote:
> Hi,
>
> Brendan Gillatt wrote:
>> On Mon, 2 Jul 2007 14:47:42 +0100, "Geoff" <someone@home.uk> wrote:
>>
>>> I want to create an on-line form & into one of the text boxes the
>>> visitor will enter his email address. So far so good. However,
>>> when that form is emailed to me, I want that email address to appear
>>> in the "From" field of the email. I know this cannot be done in
>>> HTML because the variable cannot be transferred across pages, but can
>>> it be done in PHP? Or is there another way of achieving it?
>>>
>>> Any advice much appreciated and if there are any sample scripts
>>> anywhere, even more appreciated.

>
>> $from = $_POST['emailaddress'];
>>
>> $to = 'someemail@aol.com';
>>
>> $subject = $_POST['subject'];
>>
>> mail($to, $subject, $msg, "From: $from\n");

>
> Never, never, never ever do it this way without any proper input
> validation! Using $_POST is not enough to validate the values coming
> from a form. You should never trust them!
>
> For example, $name should at least be validated this way:


$subject of course.

Alex
  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 08h39.


É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,10615 seconds with 12 queries