Jump to content

contact form issues with check boxes


cmbcorp

Recommended Posts

hi guys and gals,

 

having some issues with my code with a contact form.

 

below is my html form code

 

 
<form method="post" action="sendtraining.php">			
				<p>			
				<label>Department:</label>  
				<select name="sendto">
                <option value="[email protected]" selected="selected">Training Department</option>
                    </select></label>
				<br />
				<label><span class="style1">*</span> Name</label>
				<input name="Name" value="Your Name" type="text" size="30" />
				<label><span class="style1">*</span> Company Name</label>
				<input name="Company" value="Company Name" type="text" size="30" />
				<label><span class="style1">*</span> Email</label>
				<input name="Email" value="Your Email" type="text" size="30" />
				<label><span class="style1">*</span> Phone Number</label>
				<input name="Phone" value="Your Phone Number" type="text" size="30" />
<label>Additional Training Modules </label>
<input type="checkbox" name="check1" value="y" /> 
Reporting<br /> 
<input type="checkbox" name="check2" value="y" />
Advanced Stock Management (Promotions, Audit trails, Deletions, Transfers etc.)<br />
<input type="checkbox" name="check3" value="y" /> 
POS Training overview<br />
<input type="checkbox" name="check4" value="y" />
Customer Managment (Special pricing, loyalty, customer profiling) 
<br />
<label>Other (Please specify below) </label>
				<textarea name="Message" rows="5" cols="5"></textarea>
				<br />	
				<input type="submit" name="send" value="Submit" />
				<br />
				<span class="style1">*</span>	Iindicates a 
field is required</p>		
			</form>		

 

and below is my validation code

<?php 
$to = $_REQUEST['sendto']; 
$from = $_REQUEST['Email']; 
$name = $_REQUEST['Name']; 
$company = $_REQUEST['Company'];
$phone = $_REQUEST['Phone'];  

$headers = "From: $from"; 
$subject = "RetailCare.com.au - Free Consulting Session - Conctact Form"; 

$fields = array(); 
$fields{"Name"} = "Name"; 
$fields{"Company"} = "Company"; 
$fields{"Email"} = "Email"; 
$fields{"Phone"} = "Phone"; 
$fields{"Message"} = "Message"; 

$check1 = $_POST['check1']; 
$check2 = $_POST['check2']; 
$check3 = $_POST['check3']; 
$check4 = $_POST['check4']; 


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

$headers2 = "From: [email protected]"; 
$subject2 = "Thank you for contacting us"; 
$autoreply = "Thank you for for your query. A Sales representitive will be in contact with you shortly!.";

if ($check1 == "y") { 
$req1 = "Reporting \n" ; 
}

if ($check2 == "y") {
$req2 = "Advanced Stock Management \n";
}
if ($check3 == "y") {
$req3 = "POS Training overview \n";
}
if ($check4 == "y") {
$req4 = "Customer Managment \n";
}

$req = $req1 . $req2 . $req3 . $req4 . $req5;

if($from=='') {print "You have not entered an email, please go back and try again";} 
if($name=='') {print "You have not entered a name, please go back and try again";} 
if($phone=='') {print "You have not entered a phone number, please go back and try again";} 
if($company=='') {print "You have not entered a company name, please go back and try again";} 

else 
{ 
$send = mail($to, $subject, $body, $headers); 
$send2 = mail($from, $subject2, $autoreply, $headers2); 
	if($send) 
	{
	header("Location: http://www.retailcare.com.au/thankyou.html");
	} 
	else 
	{
	echo "We encountered an error sending your mail, please notify [email protected]"; 
	}
}

?>

 

My problem i am having is that the check boxers arnt working, meaning if you were to fill the form out an email gets sent, but no check box information is being sent.

 

I know i have done something wrong.

 

Would someone please help?

 

Thanks guys.

 

Regards,

Jason

Link to comment
https://forums.phpfreaks.com/topic/142739-contact-form-issues-with-check-boxes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.