Jump to content

Please help getting my email form to use checkboxes


lozbenson

Recommended Posts

Hey all,

 

This is my first post on phpfreaks... great name...

 

Please can you help me with the follow... I can not get the checkboxes to work...

 

<?php 

ini_set('display_errors',1); 
error_reporting(E_ALL);  

if(isset($_POST['send'])){ 
$from = $_REQUEST['Email'] ; 
$name = $_REQUEST['Name'] ; 
$headers = "From: $from"; 
$subject = "Web Contact Data"; 

$companies = '';
foreach($_REQUEST['Company'] as $c){  
    $companies .= "Company: $c\n";  
}  

$fields = array(); 
$fields{"Name"} = "Name"; 
$fields{"Email"} = "Email"; 
$fields{"Message"} = "Message"; 
$fields{"Company"} = "Company"; 
$departments = array("Information"=>'info@erbimages.com',"Hire"=>'hire@erbimages.com','Royalty Free'=>'rf@erbimages.com','Technical'=>'service@erbimages.com');  

$to = $departments[$_REQUEST['sendto']];   

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } 

$subject2 = "Thank you for contacting us."; 
$autoreply = "<html><body><p>Dear " . $name . ",</p><p>Thank you for registering with ERB Images.</p> 
<p>To make sure that you continue to receive our email communications, we suggest that you add info@erbimages.com to your address book or Safe Senders list. </p> 
<p>In Microsoft Outlook, for example, you can add us to your address book by right clicking our address in the 
'From' area above and selecting 'Add to Outlook Contacts' in the list that appears.</p> 
<p>We look forward to you visiting the site, and can assure you that your privacy will continue to be respected at all times.</p><p>Yours sincerely.</p><p>Edward R Benson</p><p>Edward Benson Esq.<br />Founder<br />ERB Images</p><p>www.erbimages.com</p></body></html>"; 

    $headers2  = 'MIME-Version: 1.0' . "\r\n"; 
    $headers2 .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
    $headers2 .= 'From: noreply@erbimages.com' . "\r\n"; 

    $send=false; 
    if($name == '') {$error= "You did not enter your name, please try again.";} 
    else { 
    if(!preg_match("/^[[:alnum:]][a-z0-9_.'+-]*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$/",$from)) {$error= "You did not enter a valid email address, please try again.";} 
    else { 
    $send = mail($to, $subject, $body, $headers); 
    $send2 = mail($from, $subject2, $autoreply, $headers2); 
    } 
if(!isset($error) && !$send)  
{
        $error= "We have encountered an error sending your mail, please notify service@erbimages.com"; 
        $error = $to;
}  
}   
}// end of if(isset($_POST['send'])) 
?> 

 

and here is the form:

 

				<div class="contact_section">
						<ul>
							<li>
								<b><font style="line-height: 1.5em;">Equiry form</font></b>
							</li>
							<li>
								<form method="post" action="contact.php" id="section_txt">
									<select name="sendto">
                                            <option value="Information">Information</option>
                                            <option value="Hire">Hire</option>
                                            <option value="Royalty Free">Royalty Free</option>
                                            <option value="Technical">Technical</option>
                                        </select>
							</li>
						</ul>
						<ul>
							<li id="contact_header">
								<b>Your details</b>
							</li>
							<li>
								<span style="width: 90px; float: left; text-align: right; padding-right: 6px; padding-top: 3px;"><font color=red>*</font> Name:</span>
								<span style="width: 244px; text-align: left;"><input size="30" maxlength="50" name="Name" value="<?php if(isset($_POST['Name'])) { echo $_POST['Name']; } ?>"></span>
							</li>
							<li>
								<span style="width: 90px; float: left; text-align: right; padding-right: 6px; padding-top: 3px;"><font color=red>*</font> Email:</span>
								<span style="width: 244px; text-align: left; "><input size="30" maxlength="50" name="Email" value="<?php if(isset($_POST['Email'])) { echo $_POST['Email']; } ?>"></span>
							</li>
							<li>
								<span style="width: 90px; float: left; text-align: right; padding-right: 6px; padding-top: 3px;">Company:</span>
								<span style="width: 244px; text-align: left; "><input size="30" maxlength="50" name="Company" value="<?php if(isset($_POST['Company'])) { echo $_POST['Company']; } ?>"></span>
							</li>
						</ul>
						<ul>
							<li id="contact_header">
								<b>Message</b>
							</li>
							<li id="contact_txt">
								If you&#39;re reporting a problem&#44; please feel free to copy&#47;paste the web address of the page you are describing into the field below&#46;
							</li>
							<li>
								<span style="width: 360px; float: left; text-align: center; padding-top: 3px;">
									<textarea name="Message" rows="7" cols="40"><?php if(isset($_POST['Message'])) { echo $_POST['Message']; } ?></textarea>
								</span>
							</li>
						</ul>
						<ul>
							<li id="contact_header">
								<b>Our services</b>
							</li>
							<li id="contact_txt">
								Please select the services of ours that you use or support&#46;
							</li>
							<li>
								<input type=checkbox name=Company[] value='GM'><span style="padding-left: 1em;">GM</span>
							</li>
							<li>
								<input type="checkbox" name=Company[] value="ERB" /><span style="padding-left: 1em;">ERB Images</span>
							</li>
							<li>
								<input type="checkbox" name=Company[] value="LB" /><span style="padding-left: 1em;">Lilian and Benson</span>
							</li>
							<li>
								<input type="checkbox" name=Company[] value="Otte" /><span style="padding-left: 1em;">Oscar Otte</span>
							</li>
						</ul>
						<ul>
							<li id="contact_contact_send">
								<input type="submit" name="send" value="Send" id="contact_send">
							</li>
						</ul>
                        <?php
                        ?>
					</div>

 

Can anyone help?!?!?! And correct whats wrong PLEASEEEEEEEE I am clueless  :shrug:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.