...

View Full Version : Checkboxes include in Mailto



ben_johnson1991
10-18-2009, 03:45 PM
Hey, im new to php.
Basically I have made a form to request which type of job(s) are needed, which when filled will then be sent to an email address.

The problem im having is that when more than 1 checkbox is ticked, the mailto only sends 1 of the checkedboxes.

My script for the checkboxes are:::::::
<span class="label"><span class="labelred">*</span>Job type:</span>
<label>
<input type="checkbox" name="job" value="paper" id="job_0" />
Paper Hanging</label>
<br />
<div style="margin-left:270px";><label>
<input type="checkbox" name="job" value="painting" id="job_1" />
Painting</label>
<br />
<label>
<input type="checkbox" name="job" value="insurance" id="job_2" />
Insurance Work</label>
</div>

--------------------------------------------------------------
My mailto script for this section is basically:
$_job = $_REQUEST['job']..

How do i request an individual job ID? or make the name of the checkboxes 'job' to include all th checked items in to the main body of the email?
Just so you know, in the body of the email, i simply have the $job variable added into it.

Any help would be greatful, it cant be that hard, but i have no idea!

Cheers!!

Phil Jackson
10-18-2009, 07:44 PM
I believe the problem will more than likely be with your mail server. most hosting providers will not allow spam mail to be delivered from there servers which the foot prints you make applying the above method would lead your host to believe. Create a loop, go through the loop processing 1 at a time and use sleep(13). 13seconds should be enough delay to be passed as "human".

ben_johnson1991
10-18-2009, 09:45 PM
Thanks for replying to this, but I am very new,
I've used loops once but i wouldnt know how to add this into the php, and sleep is something i've never heard of at all.

It is only the checkboxes that only sends just 1 checked item, everything else sends through fine.

Could you expand on that at all?

Phil Jackson
10-18-2009, 11:01 PM
post your html for your page (right click, view source)

ben_johnson1991
10-19-2009, 02:03 AM
This is the php script once the forms been submitted

<?php
$title =$_REQUEST['title'];
$first = $_REQUEST['first'];
$surname = $_REQUEST['surname'];
$email = $_REQUEST['email'];
$phone = $_REQUEST['phone'];
$mphone = $_REQUEST['mphone'];
$reply = $_REQUEST['reply'];
$time = $_REQUEST['time'];
$job = $_REQUEST['job'];
$comment = $_REQUEST['comment'];

$website = "www.swindonpainters.co.uk";

$to = "EMAILEMAILEMAIL ;
$subject = "Request Estimate form: $email";
$body = "The following information has been filled in.

-----------------------------------
Title: $title,
First name: $first,
Surname: $surname,
-----------------------------------
E-mail: $email,
Phone: $phone,
Mobile: $mphone,
Reply Method: $reply,
Reply Time: $time,
-----------------------------------
Job Type: $job,
Comment: $comment
-----------------------------------";
$headers = "From: $to";

$headers2 = "From: $to";
$subject2 = "Thank you for Requesting an Estimate";
$autoreply = "Thank you Requesting an Estimate.
Somebody will get back to you as soon as possible, usualy within 48 hours.
Regards, $website";


if($title == '') {print "You have not entered a Title, please go back and try again";}
else{
if($first == '') {print "You have not entered a First name, please go back and try again";}
else{
if($surname == '') {print "You have not entered your Surname, please go back and try again";}
else{
if($email == '') {print "You have not entered your Email address, please go back and try again";}
else{
if($phone == '') {print "You have not entered your Phone Number, please go back and try again";}
else{
if($reply == '') {print "You have not entered a Method to Reply, please go back and try again";}
else{
if($job == '') {print "You have not entered a Job Type, please go back and try again";}
else{
if($comment == '') {print "You have not entered a Comment or Question, please go back and try again";}
else {
$send = mail($to, $subject, $body);
$send2 = mail($email, $subject2, $autoreply);
if($send) {header ("Location: landrequest.php" );}
else
{print "We encountered an error sending your mail, please notify webmaster@bensbox.x10hosting.com"; }
}
}
}
}
}
}
}
}
?>



if you want the form page..
www.bensbox.x10hosting.com/AJs/request.php

Phil Jackson
10-19-2009, 07:51 AM
http://www.bensbox.x10hosting.com/AJs/request.php leads to a 404 error

ben_johnson1991
10-19-2009, 12:58 PM
http://www.bensbox.x10hosting.com/AJs/request.php leads to a 404 error

my apolagise, ive since changed it
http://bensbox.x10hosting.com/AJs/request_est.php

Phil Jackson
10-19-2009, 06:24 PM
name="job" on you check boxes should be name="job[]"

and try:



<?php
$title =$_POST['title'];
$first = $_POST['first'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$mphone = $_POST['mphone'];
$reply = $_POST['reply'];
$time = $_POST['time'];
$job = $_POST['job'];
$comment = $_POST['comment'];

$website = "www.swindonpainters.co.uk";

$to = "EMAILEMAILEMAIL" ;
$subject = "Request Estimate form: $email";
$body = "
The following information has been filled in.
-----------------------------------
Title: $title,
First name: $first,
Surname: $surname,
-----------------------------------
E-mail: $email,
Phone: $phone,
Mobile: $mphone,
Reply Method: $reply,
Reply Time: $time,
-----------------------------------
Job Type: ".implode(", ", $job).",
Comment: $comment
-----------------------------------
";
$headers = "From: $to";

$headers2 = "From: $to";
$subject2 = "Thank you for Requesting an Estimate";
$autoreply = "Thank you Requesting an Estimate.
Somebody will get back to you as soon as possible, usualy within 48 hours.
Regards, $website";


if($title == '') {
print "You have not entered a Title, please go back and try again";}
else{
if($first == '') {print "You have not entered a First name, please go back and try again";}
else{
if($surname == '') {print "You have not entered your Surname, please go back and try again";}
else{
if($email == '') {print "You have not entered your Email address, please go back and try again";}
else{
if($phone == '') {print "You have not entered your Phone Number, please go back and try again";}
else{
if($reply == '') {print "You have not entered a Method to Reply, please go back and try again";}
else{
if($job == '') {print "You have not entered a Job Type, please go back and try again";}
else{
if($comment == '') {print "You have not entered a Comment or Question, please go back and try again";}
else {
$send = mail($to, $subject, $body);
$send2 = mail($email, $subject2, $autoreply);
if($send) {header ("Location: landrequest.php" );}
else
{print "We encountered an error sending your mail, please notify webmaster@bensbox.x10hosting.com"; }
}
}
}
}
}
}
}
}
?>


$job should be an array. if(is_array($job)){ echo "yup hes right"; } and using implode should print as string.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum