[SOLVED] Form to email with checkbox

This is a discussion on "[SOLVED] Form to email with checkbox" within the PHP Forum section. This forum, and the thread "[SOLVED] Form to email with checkbox are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 29th, 2007, 00:40
New Member
Join Date: Oct 2007
Location: Manchester
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Smile [SOLVED] Form to email with checkbox

Hi,
Im am using a form to collect data, which is then sent to a specified email address.
Simple enough, but i need the checkbox to give two diferent results.
First see my code:

HTML: Select all
<form method="post" action="get_a_quote_submission.php">
<table>
<tr>
<td colspan="2">
<div class="header_1">
Get a quote</div>
<br /></td>
</tr>
<tr>
<td>
Name</td>
<td>
<input  name="name" type="text" class="form" size="20" /></td>
</tr>
<tr>
<td>
Company</td>
<td>
<input  name="company" type="text" class="form" size="20" /></td>
</tr>
<tr>
<td>
Phone</td>
<td>
<input name="phone" type="text" class="form" size="20" /></td>
</tr>
<tr>
<td>
Email</td>
<td>
<input name="email" type="text" class="form"size="20" /></td>
</tr>
<tr>
<td> 
URL</td>
<td>
<input name="url" type="text" class="form" size="20" /></td>
<td>
<img src="qm.jpg" alt="This is your website address, e.g. http://www.yourwebsite.co.uk" title="This is your website address, e.g. http://www.yourwebsite.co.uk" style="margin : 0"></td>
</tr>
<tr>
<td>
Service</td>
<td>
<select name="service" class="form" size="1">
<option value="Did not specify"> - - Please select - - </option>
<option value="Web design">Web design</option>
<option value="Logo design">Logo design</option>
<option value="Training">Training</option>
<option value="IT solutions">IT solutions</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td>
Message</td>
<td>
<textarea name="message" class="form" cols="20" rows="6"></textarea></td>
</tr>
<tr>
<td colspan="2">
Receive newsletter &nbsp; &nbsp; <input type="checkbox" name="newsletter" value="newsletter" /> 
</td>
<td>
<img src="qm.jpg" alt="We may occasionally send you a newsletter to the specified email address" title="We may occasionally send you a newsletter to the specified email address" style="margin : 0"></td>
</tr>
<tr>
<td></td>
<td>
<br /><br /><br />
<input type="submit" value=" Submit " class="form"> <input type="reset" value=" Reset " class="form"></td>
</tr>
</table>
</form>
PHP: Select all

<?php
ini_set
("sendmail_from""info@its-design.co.uk") ;
$name $_REQUEST['name'] ;
$company $_REQUEST['company'] ;
$phone $_REQUEST['phone'] ;
$email $_REQUEST['email'] ;
$url $_REQUEST['url'] ;
$service $_REQUEST['service'] ;
$message $_REQUEST['message'] ;
$newsletter $_REQUEST['newsletter'] ;
mail"info@its-design.co.uk"
"Get a quote submission"
"$name has requested a quote from ITS - Design
\n
The company is - $company
\n
The phone number is - $phone
\n
The email address is - $email
\n
The URL is - $url
\n
The service they require is - $service
\n
The message reads - $message
\n
They $newsletter to subscribe to the newsletter"
,
"From: $email");
header"Location: http://www.its-design.co.uk/thank_you_quote.htm" ) ;
?>
Basically i want "$newsletter" to display "want" if the checkbox is checked and "dont want" if the checkbox is unchecked.

Thanks in advance.

  #2 (permalink)  
Old Oct 29th, 2007, 00:45
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email with checkbox

Just check if it has a value at all ( as PHP only send it if the checkbox is set..)

$newsletter = !empty($_REQUEST['newsletter']) ? 'Want' : 'Don\'t Want' ;
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
  #3 (permalink)  
Old Oct 29th, 2007, 00:51
New Member
Join Date: Oct 2007
Location: Manchester
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email with checkbox

that works fine but i get this error message when the checkbox is not selected and the form is submitted:

Notice: Undefined index: newsletter in e:\domains\i\its-design.co.uk\user\htdocs\get_a_quote_submission.ph p on line 10

Warning: Cannot modify header information - headers already sent by (output started at e:\domains\i\its-design.co.uk\user\htdocs\get_a_quote_submission.ph p:10) in e:\domains\i\its-design.co.uk\user\htdocs\get_a_quote_submission.ph p on line 30
  #4 (permalink)  
Old Oct 29th, 2007, 00:52
New Member
Join Date: Oct 2007
Location: Manchester
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form to email with checkbox

oh, i fixed it know, thanks for you help, it was a very rapid response.
  #5 (permalink)  
Old Oct 29th, 2007, 00:57
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: [SOLVED] Form to email with checkbox

If you could post how you fixed it for other people to learn, that would be great.
Also, since this is solved, please mark it as solved via thread tools at the top of this page.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Closed Thread

Thread Tools

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] help with checkbox and textfield in form BRONIC JavaScript Forum 8 Apr 22nd, 2008 16:08
[SOLVED] Form to email script with checkboxes Posie PHP Forum 4 Dec 10th, 2007 03:54
[SOLVED] Form Checkbox Validation Stuart PHP Forum 26 Nov 24th, 2007 23:39
[SOLVED] sending email once form submitted Emzi PHP Forum 5 Nov 21st, 2007 14:25
[SOLVED] Form Submit To Email longstand PHP Forum 17 Nov 13th, 2007 13:16


All times are GMT. The time now is 20:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43