For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2006 > Simple php form Help









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 Simple php form Help
Juan Antonio Villa

2006-03-22, 6:58 pm

Hello All. I'm a newbie in programming and I was wondering if I could get
some help from you.

I have a form with the following fields:
-------------------------------------------------
Name
Email
Age (option field) -> over 45 or under 45
Sex (option field) -> male or female
Comments:
-------------------------------------------------


I currently submit this form to Formmail.cgi (Im sure you're familiar with
it) and I get it in an email.

What I need to do is that IF:
- Age is Over 45 and sex is male then send "this" via email to the <email>
field and i want to receive an email with the results of the form.
- Age is Under 45 and sex is male then send "this" via email to the <email>
field and i want to receive an email with the results of the form.
- Age is Over 45 and sex is female then send "this" via email to the <email>
field and i want to receive an email with the results of the form.
- Age is Under 45 and sex is female then send "this" via email to the
<email> field and i want to receive an email with the results of the form.

Could you give me a hint on how to acomplish this using PHP?

Thank you very much!

Juan


bobzimuta

2006-03-22, 6:58 pm

Please, read the documentation on forms

http://us2.php.net/manual/en/tutorial.forms.php

As a hint you will need to access elements of the $_POST array. Such as
$_POST['age'] and $_POST['sex'].

When I'm stuck, I use the following to show all the post data that has
been submitted
if( isset( $_POST ) && !empty( $_POST ) )
{
exit( "<pre>" . print_r( $_POST, true ) . "</pre>" );
}
else
{
exit( "POST is empty, submit a form" );
}

JDS

2006-03-22, 6:58 pm

On Wed, 22 Mar 2006 13:53:52 -0500, Juan Antonio Villa wrote:

> I currently submit this form to Formmail.cgi (Im sure you're familiar with
> it) and I get it in an email.


Why are you so sure?

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

JDS

2006-03-22, 6:58 pm

On Wed, 22 Mar 2006 13:53:52 -0500, Juan Antonio Villa wrote:

> Could you give me a hint on how to acomplish this using PHP?
>
> Thank you very much!
>
> Juan


Sorry, but this is too broad a question to answer here.

--
JDS | jeffrey@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Duderino82

2006-03-23, 7:58 am

Can't you just manage the if-then-else by yourself in php and then use
the mail() function???so easy so simple!

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com