Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I need help with this simple php script! Can anyone help me please?
Old 01-26-2010, 01:00 PM I need help with this simple php script! Can anyone help me please?
Experienced Talker

Posts: 35
Name: Matthew Cook
Trades: 0
Hi, I have a basic form that I need to make work with PHP.

All I have in the form is text fields, check boxes and text areas.

I have one php script that works when I have 2 text fields and 1 text area:

Code:
PHP Code:
<?php
if(isset($_POST['submit'])) {

$to "email@email.com";
$subject "Contact Form";
$name_field $_POST['name'];
$email_field $_POST['email'];
$message $_POST['comments'];
 
$body "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
 
header("Location: ../thankyou.htm");
mail($to$subject$body);

} else {

echo 
"error: no data sent!";

}
?>


Can you please give me an example of how to change this code for a form that has 7 text feilds, 6 checkboxes and 1 text area.

I know that it will depend on the names of the different input areas of the form but if you give me a rough example of how to add more to this php then I will be able to set this form up.

I know that there are just a few things to add in the php script but I don't know the exact way to add them. If anyone could help me with this then that would be unbelievable!

Thanks!
__________________

Please login or register to view this content. Registration is FREE
- Fastest growing Winnipeg website design company
mcook is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-26-2010, 01:34 PM Re: I need help with this simple php script! Can anyone help me please?
Experienced Talker

Posts: 31
Trades: 0
Hi Mcook,


Try this:
*Make sure that you fill in the names of what you defined the textboxes, checkboxes, etc from your other page!

PHP Code:
<?php
if(isset($_POST['submit'])) {

$to "email@email.com";
$subject "Contact Form";
$name_field $_POST['name'];
$email_field $_POST['email'];
$message $_POST['comments'];

//**ADDON FOR THE OTHER FIELDS**
//Text Fields
$txtfield1 $_POST['NAME HERE'];
$txtfield2 $_POST['NAME HERE'];
$txtfield3 $_POST['NAME HERE'];
$txtfield4 $_POST['NAME HERE'];
$txtfield5 $_POST['NAME HERE'];
$txtfield6 $_POST['NAME HERE'];
$txtfield7 $_POST['NAME HERE'];
$txtfield8 $_POST['NAME HERE'];

//Check Boxes
//Whatever the name is that you called the check boxes
//EXAMPLE: <input type="checkbox" name="NAME HERE" value="a">

$chkbox1 $_POST['NAME HERE'];
$chkbox2 $_POST['NAME HERE'];
$chkbox3 $_POST['NAME HERE'];
$chkbox4 $_POST['NAME HERE'];
$chkbox5 $_POST['NAME HERE'];
$chkbox6 $_POST['NAME HERE'];

//TEXT AREA
$txtarea1 $_POST['NAME HERE'];


$body "From: $name_field\n E-Mail: $email_field\n Message:\n $message\n Text Field1: $txtfield1\n Text Field2: $txtfield2\n Text Field3: $txtfield3\n Text Field4: $txtfield4\n Text Field5: $txtfield5\n Text Field6: $txtfield6\n Text Field7: $txtfield7\n Text Field8: $txtfield8\n CheckBox1: $chkbox1\n CheckBox2: $chkbox2\n CheckBox3: $chkbox3\n CheckBox4: $chkbox4\n CheckBox5: $chkbox5\n CheckBox6: $chkbox6\n TextArea1: $txtarea1";
 
header("Location: ../thankyou.htm");
mail($to$subject$body);

} else {

echo 
"error: no data sent!";

}
?>
Hope this helps!

-Dillon

Last edited by Dillon; 01-26-2010 at 01:39 PM..
Dillon is offline
Reply With Quote
View Public Profile
 
Old 01-26-2010, 03:18 PM Re: I need help with this simple php script! Can anyone help me please?
blackblue's Avatar
Junior Talker

Posts: 1
Trades: 0
thank you dillon
__________________

Please login or register to view this content. Registration is FREE
blackblue is offline
Reply With Quote
View Public Profile
 
Old 01-26-2010, 03:43 PM Re: I need help with this simple php script! Can anyone help me please?
Experienced Talker

Posts: 31
Trades: 0
Your Welcome! I was glad to help out!

-Dillon
Dillon is offline
Reply With Quote
View Public Profile
 
Old 01-26-2010, 03:44 PM Re: I need help with this simple php script! Can anyone help me please?
Experienced Talker

Posts: 35
Name: Matthew Cook
Trades: 0
Wow! Thank you very much. I really appreciate that!
__________________

Please login or register to view this content. Registration is FREE
- Fastest growing Winnipeg website design company
mcook is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I need help with this simple php script! Can anyone help me please?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14942 seconds with 12 queries