...

View Full Version : need a help with checkbox menu



mursallo
08-21-2011, 06:18 PM
my html code
<tr>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="BusinessCards[]" value="BusinessCards"><img src="images/form-businesscards.jpg" border="0" alt=" /">
</td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="Brochures[]" value="Brochures"><img src="images/form-brochures.jpg" border="0" alt=" /">
</td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="FlyerDesign[]" value="FlyerDesign"><img src="images/form-flyer-design.jpg".jpg" border="0" alt=" /">
</td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="LogoDesign"><img src="images/form-logo-design.jpg".jpg" border="0" alt=" /">
</td>
</tr>


<tr><td width="750" height="20" colspan="7"></td></tr>


<tr>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#000000; font-family:Futura, Arial, sans-serif" background="images/portfolio-bgC.jpg">
Page Layout
</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#000000; font-family:Futura, Arial, sans-serif" background="images/portfoliobgSky.jpg">
Poster Design
</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#ffffff; font-family:Futura, Arial, sans-serif" background="images/portfoliobgSky.jpg">
Videography</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#000000; font-family:Futura, Arial, sans-serif" background="images/portfolio-bgGold.jpg">
T Shirt Design
</td>
</tr>

<tr>
<td width="170" height="177" valign="bottom" align="center"><input type="CHECKBOX" name="PageLayout[]" value="PageLayout">
<img src="images/form-page-layout.jpg" width="170" height="177" alt="page layout"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center"><input type="CHECKBOX" name="PosterDesign[]" value="PosterDesign">
<img src="images/form-poster-design.jpg" width="170" height="177" alt="poster design"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="Videography[]" value="Videography"><img src="images/form-Videography.jpg" width="170" height="177" alt="Videography"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="TShirtDesign[]" value="TShirtDesign"><img src="images/form-tshirt-design.jpg" width="170" height="177" alt="Tshirt design"></td>
</tr>


<tr><td width="750" height="20" colspan="7"></td></tr>


<tr>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#ffffff; font-family:Futura, Arial, sans-serif" background="images/portfolio-bgP.jpg">
Media Commercial
</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#ffffff; font-family:Futura, Arial, sans-serif" background="images/portfoli-bgB.jpg">
Web Design
</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#000000; font-family:Futura, Arial, sans-serif" background="images/portfolio-bgC.jpg">
Photography
</td>
<td width="10"></td>
<td width="170" height="30" valign="center" align="center" style="font-size:17px; background-color:#cccccc; color:#ffffff; font-family:Futura, Arial, sans-serif" background="images/portfoliobgM.jpg">
SEO
</td>
</tr>

<tr>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="RandomDesign[]" value="RandomDesign"><img src="images/form-MediaCommercial .jpg" width="170" height="177" alt="Media Commercial"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="WebDesign[]" value="WebDesign"><img src="images/form-web-design.jpg" width="170" height="177" alt="Web Design"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="Photography[]" value="Photography"><img src="images/form-photography.jpg" width="170" height="177" alt="Photography"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="CHECKBOX" name="SEO[]" value="SEO"><img src="images/form-SEO.jpg" width="170" height="177" alt="SEO"></td>
</tr>




And my php code


<?php

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mursallotest@msn.com";
$email_subject = "Hello";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}


$first_name = $_POST['FirstName']; // required
$last_name = $_POST['LastName']; // required
$city = $_POST['City']; // required
$state = $_POST['State']; // required
$o = $_POST['O']; // required
$q = $_POST['Q']; // required
$n_s = $_POST['NS']; // required
$n_b = $_POST['NB']; // required
$m = $_POST['M']; // required
$b_c = $_POST['BC']; // required
$p_i = $_POST['PI']; // required
$s = $_POST['S']; // required
$a = $_POST['A']; // required
$n_l = $_POST['NL']; // required

$postal_code = $_POST['Postalcode']; // required
$email_address = $_POST['EmailAddress']; // required
$work_phone = $_POST['WorkPhone']; // not required
$mobile_phone = $_POST['MobilePhone']; // required

$business_cards = $_POST['BusinessCards']; // required
$brochures = $_POST['Brochures']; // required
$flyer_design = $_POST['FlyerDesigne']; // not required
$logo_design = $_POST['LogoDesign']; // required
$page_layout = $_POST['PageLayout']; // required
$poster_design = $_POST['PosterDesign']; // required
$videography = $_POST['Videography']; // not required
$tshirt_design = $_POST['TShirtDesign']; // required
$random_design = $_POST['RandomDesign']; // required
$web_design = $_POST['Web Design']; // required
$photography = $_POST['Photography']; // not required
$seo = $_POST['SEO']; // required
$personal_commercial = $_POST['PersonalCommercial']; // required
$completed_by = $_POST['CompletedBy']; // required
$referral = $_POST['Referral']; // not required
$comments = $_POST['Your_Message'];


$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_address)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";
$email_message .= "Ontario: ".clean_string($o)."\n";
$email_message .= "Quebec: ".clean_string($q)."\n";
$email_message .= "Nova Scotia: ".clean_string($n_s)."\n";
$email_message .= "New Brunswick: ".clean_string($n_b)."\n";
$email_message .= "Manitoba: ".clean_string($m)."\n";
$email_message .= "British Columbia: ".clean_string($b_c)."\n";
$email_message .= "Prince Edward Island: ".clean_string($p_i)."\n";
$email_message .= "Saskatchewan: ".clean_string($s)."\n";
$email_message .= "Alberta: ".clean_string($a)."\n";
$email_message .= "Newfoundland and Labrador:".clean_string($n_l)."\n";
$email_message .= "Postal Code: ".clean_string($postal_code)."\n";
$email_message .= "Email Address: ".clean_string($email_address)."\n";
$email_message .= "Work Phone: ".clean_string($work_phone)."\n";
$email_message .= "Mobile Phone: ".clean_string($mobile_phone)."\n";


$email_message .= "Business Cards: ".clean_string($business_cards)."\n";
$email_message .= "Brochures: ".clean_string($brochures)."\n";
$email_message .= "Flyer Design: ".clean_string($flyer_design)."\n";
$email_message .= "logo Design: ".clean_string($logo_design)."\n";
$email_message .= "Page Layout: ".clean_string($page_layout)."\n";
$email_message .= "Poster Design: ".clean_string($poster_design)."\n";
$email_message .= "Videography: ".clean_string($videography)."\n";
$email_message .= "TShirt Design: ".clean_string($tshirt_design)."\n";
$email_message .= "Random Design: ".clean_string($random_design)."\n";
$email_message .= "Web Design: ".clean_string($web_design)."\n";
$email_message .= "Photography: ".clean_string($photography)."\n";
$email_message .= "SEO: ".clean_string($seo)."\n";


$email_message .= "Personal Commercial: ".clean_string($personal_commercial)."\n";
$email_message .= "Completed By: ".clean_string($completed_by)."\n";
$email_message .= "Referral: ".clean_string($referral)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.



<?php

?>


Iam getting email with all checkboxes name dont know why even tho when I check only one in the form but I get email it shows all of them....can someone please tell me what i have done wrong here ....thanks

mlseim
08-21-2011, 06:43 PM
Copy one of those emails to a text file and show it to us.
I want to see what you mean by "it's showing you all checkboxes".



.

mursallo
08-21-2011, 07:23 PM
Form details below.

First Name: john
Last Name: edward
City: toronto
State: O
Ontario:
Quebec:
Nova Scotia:
New Brunswick:
Manitoba:
British Columbia:
Prince Edward Island:
Saskatchewan:
Alberta:
Newfoundland and Labrador:
Postal Code: m3c1e6
Email Address: mursallo@msn.com
Work Phone: 4168529632
Mobile Phone: 4162583692
Business Cards:
Brochures: Array THIS IS WHAT I GET ARRAY AND BELOW OTHER CHECKBOX NAMES
Flyer Design:
logo Design:
Page Layout:
Poster Design:
Videography:
TShirt Design:
Random Design:
Web Design:
Photography:
SEO:
Personal Commercial: commercial
Completed By: 1 month
Referral: google
Comments: Just testing the email thank you ....



i ONLY CHECK THE Brochures AND i GET ALL OTHER CHECKBOXES NAME....
check the form link http://www.mxstudio.ca/requestquote.html

Iam also getting my province name listed all of them I don't what i done wrong here

Here is my HTML FULL CODE FOR THE PROVINCE SECTION.......


<tr>
<td wiidth="360" height="35" valign="center" align="left" style="font-size:16px; padding-right:8px;">Province<font color="#CC3300">*</font>
</td>
<td wiidth="360" height="35" valign="center" align="left" style="font-size:16px; padding-right:8px;">

<select name="State">
<option value="O">Ontario</option>
<option value="Q">Quebec</option>
<option value="NS">Nova Scotia</option>
<option value="NB">New Brunswick</option>
<option value="M">Manitoba</option>
<option value="BC">British Columbia</option>
<option value="PI">Prince Edward Island</option>
<option value="S">Saskatchewan</option>
<option value="A">Alberta</option>
<option value="NL">Newfoundland and Labrador</option>



</select>

</td>
</tr>

Fou-Lu
08-21-2011, 07:52 PM
I don't think this is what you want your HTML to be. Seems to me like the intent is to choose which items to create yes? Like a choice of services?
For this type, you would retain the same name for all of your checkboxes (ie: item[]). You then specify the value that you want that checkbox to represent, and if selected it will be available in the $_POST['item'] array. Note that checkboxes are one of the only fields that will only be passed if at least one was selected, it otherwise is optional by the browser. The real pro to this is you can simply implode the options with an $services = isset($_POST['item']) && is_array($_POST['item']) ? implode(', ', $_POST['item']) : ''; which would result in if I selected BusinessCards and TShirtDesign a result of BusinessCards, TShirtDesign. You can also use a urlencoded value to retain spaces if you like (%20).

As for the provinces, you only need to select what is in the 'State' section of the $_POST. These are select options without a multiple option set. So you can only ever have one; $_POST['State'] if Saskatchewan is selected will return 'S'. I'd actually recommend you use a more normalized approach with this, and use the actual provincial abbreviations.

In the future, wrap all of your code in
or
tags to preserve the format of the code.

mursallo
08-21-2011, 08:06 PM
wow you guyz are so quick in answer nice like that ....best forum for very quick reply thanks..okay Fou_Lu I didn't get you proper do you mind giving me some example of one or two code and so i can see how u did it....cuz iam new in this php contact form... so iam little bit slow sorry for that.....i precaite your help tho.....thanks

Mursallo

mursallo
08-21-2011, 08:16 PM
wow THANKS FOU-LU I GOT MY PROVINCE SECTION BETTER NOW THANKS FOR YOUR HELP ....NOW I ONLY NEED A HELP IN CHECKBOX SECTION....TAKE A LOOK BELOW THE EMAIL TEXT I GOT FOR THE FORM....


Form details below.

First Name: mursallo
Last Name: john
City: toronto
State: Quebec
Postal Code: m3c1c7
Email Address: mursallo@msn.com
Work Phone: 4162586325
Mobile Phone: 4165287412
Business Cards:
Brochures: Array
Flyer Design:
logo Design:
Page Layout:
Poster Design:
Videography:
TShirt Design:
Random Design:
Web Design:
Photography:
SEO:
Personal Commercial: commercial
Completed By: 1 month
Referral: google
Comments: just testing thank you...

Fou-Lu
08-21-2011, 08:24 PM
For an html, we'll keep this simple:


<input type="checkbox" name="services[]" value="Business%20Cards" />
<input type="checkbox" name="services[]" value="Flyer%20Design" />
<input type="checkbox" name="services[]" value="Logo%20Design" />
<input type="checkbox" name="services[]" value="Page%20Layout" />
....

Where in PHP, assume that the method was post:


$sChecked = isset($_POST['services']) && is_array($_POST['services']) ? implode(', ', $_POST['services']) : '';
printf("You have selected the following services: %s", $sChecked);


Nice and simple.


Oh btw, you can apply your clean_string function to every item in the array using $_POST['services'] = array_map('clean_string', $_POST['services']);. So to keep it nice, you'll want to skip the ternary:


if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = implode(', ', $aServices);
printf('Selected services: %s', $sServices);
}

mursallo
08-21-2011, 08:52 PM
Okay no iam still getting all of them in email here the code for html and php ..

HTML
<tr>
<td width="170" height="177" valign="bottom" align="center">
<input type="checkbox" name="services[]" value="Random%20Design" /><img src="images/form-MediaCommercial .jpg" width="170" height="177" alt="Media Commercial"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="checkbox" name="services[]" value="Web%20Design" /><img src="images/form-web-design.jpg" width="170" height="177" alt="Web Design"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="checkbox" name="services[]" value="Photography" /><img src="images/form-photography.jpg" width="170" height="177" alt="Photography"></td>
<td width="10"></td>
<td width="170" height="177" valign="bottom" align="center">
<input type="checkbox" name="services[]" value="SEO" /><img src="images/form-SEO.jpg" width="170" height="177" alt="SEO"></td>
</tr>


PHP CODE

<?php

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mursallotest@msn.com";
$email_subject = "Hello";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}


$first_name = $_POST['FirstName']; // required
$last_name = $_POST['LastName']; // required
$city = $_POST['City']; // required
$state = $_POST['State']; // required
$postal_code = $_POST['Postalcode']; // required
$email_address = $_POST['EmailAddress']; // required
$work_phone = $_POST['WorkPhone']; // not required
$mobile_phone = $_POST['MobilePhone']; // required





if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = implode(', ', $aServices);
printf('Selected services: %s', $sServices);
}

$personal_commercial = $_POST['PersonalCommercial']; // required
$completed_by = $_POST['CompletedBy']; // required
$referral = $_POST['Referral']; // not required





$comments = $_POST['Your_Message'];


$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_address)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";

$email_message .= "Postal Code: ".clean_string($postal_code)."\n";
$email_message .= "Email Address: ".clean_string($email_address)."\n";
$email_message .= "Work Phone: ".clean_string($work_phone)."\n";
$email_message .= "Mobile Phone: ".clean_string($mobile_phone)."\n";


$email_message .= "Business Cards: ".clean_string($business_cards)."\n";
$email_message .= "Brochures: ".clean_string($brochures)."\n";
$email_message .= "Flyer Design: ".clean_string($flyer_design)."\n";
$email_message .= "logo Design: ".clean_string($logo_design)."\n";
$email_message .= "Page Layout: ".clean_string($page_layout)."\n";
$email_message .= "Poster Design: ".clean_string($poster_design)."\n";
$email_message .= "Videography: ".clean_string($videography)."\n";
$email_message .= "TShirt Design: ".clean_string($tshirt_design)."\n";
$email_message .= "Random Design: ".clean_string($random_design)."\n";
$email_message .= "Web Design: ".clean_string($web_design)."\n";
$email_message .= "Photography: ".clean_string($photography)."\n";
$email_message .= "SEO: ".clean_string($seo)."\n";


$email_message .= "Personal Commercial: ".clean_string($personal_commercial)."\n";
$email_message .= "Completed By: ".clean_string($completed_by)."\n";
$email_message .= "Referral: ".clean_string($referral)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.



<?php

?>

SUPPOSE TO BE LIKE THIS OR NO.....

Fou-Lu
08-21-2011, 08:57 PM
You are still getting them in the email since you have not removed them. You want to move that code in place of where it should appear and assign the implode to the $email_message concatination instead of printing it.

mursallo
08-21-2011, 09:04 PM
Okay I change the code from implode to $email_message below is the example.....now i get this message after submiting the form ( Fatal error: Function name must be a string in /home4/tayebdes/public_html/mxstudio/send_form_email.php on line 34 )


if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = $email_message(', ', $aServices);
printf('Selected services: %s', $sServices);
}

Fou-Lu
08-21-2011, 09:15 PM
No no no, $sServices still remains as is. What this is trying to do is call a function declared in $email_message, but it doesn't exist:


if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = implode(', ', $aServices);
$email_message .= 'Selected Services: ' . $sServices;
}


Don't forget to use
tags around your PHP code.

mursallo
08-21-2011, 09:24 PM
still the same iam getting all of them....

Form details below.

First Name: mursallo
Last Name: john
City: toronto
State: Nova Scotia
Postal Code: m2c4g7
Email Address: mursallo@msn.com
Work Phone: 4167859623
Mobile Phone: 4165287412
Business Cards:
Brochures:
Flyer Design:
logo Design:
Page Layout:
Poster Design:
Videography:
TShirt Design:
Random Design:
Web Design:
Photography:
SEO:
Personal Commercial: commercial
Completed By: 1 month
Referral: google
Comments: just testing thank you...


IS MY PHP CODE RITE CUZ SOMETHING LOOK FISHY TO ME WHAT YOU THINK???

Fou-Lu
08-21-2011, 09:37 PM
Did you remove those from the email section? And move the new block into their place? Post the current code you are using.

mursallo
08-21-2011, 09:44 PM
Okay I remove the email section and what you mean by new block?? this is what i get in email no checkbox after removing the email section..

Form details below.

First Name: mursallo
Last Name: john
City: toronto
State: Quebec
Postal Code: m2c4g7
Email Address: mursallo@msn.com
Work Phone: 4167859623
Mobile Phone: 4165287412
Personal Commercial: commercial
Completed By: 1month
Referral: google
Comments: just testing

Fou-Lu
08-21-2011, 09:57 PM
Okay I remove the email section and what you mean by new block?? this is what i get in email no checkbox after removing the email section..

Form details below.

First Name: mursallo
Last Name: john
City: toronto
State: Quebec
Postal Code: m2c4g7
Email Address: mursallo@msn.com
Work Phone: 4167859623
Mobile Phone: 4165287412
Personal Commercial: commercial
Completed By: 1month
Referral: google
Comments: just testing


...Post the current code you are using.

As above.

mursallo
08-21-2011, 10:07 PM
lolz iam lost seriously what you mean by current code lolz iam about to hit my head over the wall lol please help me I don't know what iam doing can you give me some example please please ....what current code iam looking for ??? okay here is my php code tell me what is my current code in here ??

<?php

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mursallo@gmail.com";
$email_subject = "Hello";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}


$first_name = $_POST['FirstName']; // required
$last_name = $_POST['LastName']; // required
$city = $_POST['City']; // required
$state = $_POST['State']; // required
$postal_code = $_POST['Postalcode']; // required
$email_address = $_POST['EmailAddress']; // required
$work_phone = $_POST['WorkPhone']; // not required
$mobile_phone = $_POST['MobilePhone']; // required




if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = implode(', ', $aServices);
$email_message .= 'Selected Services: ' . $sServices;
}
$personal_commercial = $_POST['PersonalCommercial']; // required
$completed_by = $_POST['CompletedBy']; // required
$referral = $_POST['Referral']; // not required





$comments = $_POST['Your_Message'];


$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_address)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";

$email_message .= "Postal Code: ".clean_string($postal_code)."\n";
$email_message .= "Email Address: ".clean_string($email_address)."\n";
$email_message .= "Work Phone: ".clean_string($work_phone)."\n";
$email_message .= "Mobile Phone: ".clean_string($mobile_phone)."\n";





$email_message .= "Personal Commercial: ".clean_string($personal_commercial)."\n";
$email_message .= "Completed By: ".clean_string($completed_by)."\n";
$email_message .= "Referral: ".clean_string($referral)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.



<?php

?>

Fou-Lu
08-21-2011, 10:13 PM
Make sure you're using
tags to wrap your code. Otherwise you loose all formatting:


<?php

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "mursallo@gmail.com";
$email_subject = "Hello";


function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}


$first_name = $_POST['FirstName']; // required
$last_name = $_POST['LastName']; // required
$city = $_POST['City']; // required
$state = $_POST['State']; // required
$postal_code = $_POST['Postalcode']; // required
$email_address = $_POST['EmailAddress']; // required
$work_phone = $_POST['WorkPhone']; // not required
$mobile_phone = $_POST['MobilePhone']; // required




$personal_commercial = $_POST['PersonalCommercial']; // required
$completed_by = $_POST['CompletedBy']; // required
$referral = $_POST['Referral']; // not required





$comments = $_POST['Your_Message'];


$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_address)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "City: ".clean_string($city)."\n";
$email_message .= "State: ".clean_string($state)."\n";

$email_message .= "Postal Code: ".clean_string($postal_code)."\n";
$email_message .= "Email Address: ".clean_string($email_address)."\n";
$email_message .= "Work Phone: ".clean_string($work_phone)."\n";
$email_message .= "Mobile Phone: ".clean_string($mobile_phone)."\n";



if (isset($_POST['services']) && is_array($_POST['services']))
{
$aServices = array_map('clean_string', $_POST['services']);
$sServices = implode(', ', $aServices);
$email_message .= 'Selected Services: ' . $sServices;
}


$email_message .= "Personal Commercial: ".clean_string($personal_commercial)."\n";
$email_message .= "Completed By: ".clean_string($completed_by)."\n";
$email_message .= "Referral: ".clean_string($referral)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

mursallo
08-21-2011, 10:38 PM
Alrite FOU_LU YOUR THE BEST SERIOUSLY YOU SAVE MY LIFE LOLZ.......I WAS HAVING HARD TIME WHOLE DAY CAN'T FIXED IT YOU DID IN FEW MINUTES .....THANK YOU SO MUCH FOR YOUR GREAT HELP TO ME......THNKS

BELOW IS THE FORM FINALY ......

Form details below.

First Name: mursallo
Last Name: mursallo
City: toronto
State: New Brunswick
Postal Code: m3c1c7
Email Address: mursallo@msn.com
Work Phone: 4167859623
Mobile Phone: 4165287412
Selected Services: Page%20LayoutPersonal Commercial: personal
Completed By: 1month
Referral: google
Comments: just testing thank you....

Fou-Lu
08-22-2011, 01:48 AM
That still doesn't look right. Missing the linefeeds, so add a \n to the end of that variable. Also, looks like the %20 isn't automatically parsed as a space; use + instead.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum