Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Basic form question from a newbie

0 views
Skip to first unread message

Alan

unread,
Dec 26, 2009, 2:32:22 PM12/26/09
to
I am just learning PHP and cannot figure out how to get 4 basic data
fields from a web form to append to a file on my server. Can anyone
advise please?

form fields in html are fname, lname, email and contact

I tell the form to look to my server for a script called contact.php
but it only seems to add the first field. My eyes glaze over when the
tutorials start talking about arrays etc :)

Thanks in advance

Doug Miller

unread,
Dec 26, 2009, 2:57:43 PM12/26/09
to

Kinda hard to tell what's wrong, when you haven't posted either the html or
the php files....

Alan

unread,
Dec 26, 2009, 3:07:58 PM12/26/09
to
On Dec 26, 2:57 pm, spamb...@milmac.com (Doug Miller) wrote:

> In article <e9413e8d-07ca-4a28-b213-cf5a85cf3...@b2g2000yqi.googlegroups.com>, Alan <alaninthec...@yahoo.co.uk> wrote:
>
> >I am just learning PHP and cannot figure out how to get 4 basic data
> >fields from a web form to append to a file on my server.  Can anyone
> >advise please?
>
> >form fields in html are fname, lname, email and contact
>
> >I tell the form to look to my server for a script called contact.php
> >but it only seems to add the first field.  My eyes glaze over when the
> >tutorials start talking about arrays etc :)
>
> Kinda hard to tell what's wrong, when you haven't posted either the html or
> the php files....

oops :)

its a very basic contact.php file

<?php

$fname = $_REQUEST['fname'] ;
$lname = $_REQUEST['lname'] ;
$email = $_REQUEST['email'] ;
$cont = $_REQUEST['cnum'] ;

mail( "m...@mydomain.com", "Feedback Form Results", "From: $email",
$fname, $lname, $cnum);

if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

That says this afterwards. I'll work on getting data into a file
later but for now I can't even get it to email itself to me :(

Again, many thanks


Warning: mail() expects at most 5 parameters, 6 given in /home/
pressco1/public_html/popopweightloss.com/contact.php on line 8
We encountered an error sending your mail

Gordon Burditt

unread,
Dec 26, 2009, 4:51:05 PM12/26/09
to
>its a very basic contact.php file
>
><?php
>
> $fname = $_REQUEST['fname'] ;
> $lname = $_REQUEST['lname'] ;
> $email = $_REQUEST['email'] ;
> $cont = $_REQUEST['cnum'] ;
>
> mail( "m...@mydomain.com", "Feedback Form Results", "From: $email",
>$fname, $lname, $cnum);

This doesn't do any checking of parameters. Malicious spambots will
love to abuse this.

Why do you think that mail() has six arguments, and what does the sixth
one mean?

>if($sent)

Where did you set the value of $sent?

>{print "Your mail was sent successfully"; }
>else
>{print "We encountered an error sending your mail"; }
>?>

>That says this afterwards. I'll work on getting data into a file
>later but for now I can't even get it to email itself to me :(
>
>Again, many thanks
>
>
>Warning: mail() expects at most 5 parameters, 6 given in /home/
>pressco1/public_html/popopweightloss.com/contact.php on line 8

The above is a really strong hint that something is wrong.
Read it.

Beauregard T. Shagnasty

unread,
Dec 26, 2009, 5:46:58 PM12/26/09
to
Alan wrote:

> its a very basic contact.php file

I'd like to suggest you study this page, then use the template for your
own page. Expand as necessary, but don't change how it works.

http://safalra.com/programming/php/contact-feedback-form/

--
-bts
-Four wheels carry the body; two wheels move the soul

Peter

unread,
Dec 27, 2009, 6:36:33 AM12/27/09
to
In article <63d348a4-09aa-4fff-9375-
5e81d8...@o28g2000yqh.googlegroups.com>, alanin...@yahoo.co.uk
says...

> On Dec 26, 2:57ᅵpm, spamb...@milmac.com (Doug Miller) wrote:
> > In article <e9413e8d-07ca-4a28-b213-cf5a85cf3...@b2g2000yqi.googlegroups.com>, Alan <alaninthec...@yahoo.co.uk> wrote:
> >
> > >I am just learning PHP and cannot figure out how to get 4 basic data
> > >fields from a web form to append to a file on my server. ᅵCan anyone

> > >advise please?
> >
> > >form fields in html are fname, lname, email and contact
> >
> > >I tell the form to look to my server for a script called contact.php
> > >but it only seems to add the first field. ᅵMy eyes glaze over when the

> > >tutorials start talking about arrays etc :)
> >
> > Kinda hard to tell what's wrong, when you haven't posted either the html or
> > the php files....
>
> oops :)
>
> its a very basic contact.php file
>
> <?php
>
> $fname = $_REQUEST['fname'] ;
> $lname = $_REQUEST['lname'] ;
> $email = $_REQUEST['email'] ;
> $cont = $_REQUEST['cnum'] ;
>

I presume these variables do contain data and you have checked that.

> mail( "m...@mydomain.com", "Feedback Form Results", "From: $email",
> $fname, $lname, $cnum);
>

$cnum above should have been $cont. I take it that's a misprint.

I'm no expert, but if you are using the php mail command then it
generally contains 4 parts:

mail(customer email address, subject, message body, header info)

You have the customer email address and the subject, but you have no
body, instead you have the from part which should be included as part of
the header info. Then you have 3 other variables that you have decided
to include for some reason.

So create your $body text and put that as the 3rd part and then work on
the $header part which should contain your 'From' name and email
address,

Something along the lines of:

$header = "From: your name <your email address>\r\n"

So you'll end up with something like:

mail( "m...@mydomain.com", "Feedback Form Results", $body, $header);

Having said that you could try putting php mail into google. You're sure
to get plenty of help. Or goto:

http://www.php.net/manual/en/function.mail.php

--
Pete Ives
Remove All_stRESS before sending me an email

0 new messages