Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 07-08-2009, 05:32 PM   #1 (permalink)
Junior Member
 
Join Date: 07-08-09
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

marcman is liked by many
PHP Email Form

Hi All,

Almost working.

I get the email when filling out the online form, I get only one field reported back via email which is the Project Type from the drop down menu selection.

The layout looks great in Dreamweaver CS3.

Here's what I have:

div.row {
clear: both;
padding-top: 4px;
}
div.row span.label {
float: left;
width: 100px;
font-size: 12px;
text-align: right;
}
div.row span.formw {
float: right;
width: 180px;
text-align: left;
}
div.spacer {
clear: both;
}

Then, here's the form.

<form id="Contact" name="ContactForm" method="post" action="FormToEmail.php">
<div class="row">
<span class="label">* First Name</span><span class="formw"><input type="text" id="First Name" size="22" /></span>
</div>
<div class="row">
<span class="label">* Last Name</span><span class="formw"><input type="text" id="Last Name" size="22" /></span>
</div>
<div class="row">
<span class="label">* Email Address</span><span class="formw"><input type="text" id="Email Address" size="22" /></span>
</div>
<div class="row">
<span class="label">Phone Number</span><span class="formw"><input type="text" id="Phone Number" size="22" /></span>
</div>
<div class="row">
<span class="label">Project Location</span><span class="formw"><input id="Project Location" type="text" size="22" /></span>
</div>
<div class="row">
<span class="label">Project Type</span><span class="formw">
<select name="select" size="1" id="select">
<option>--Select--</option>
<option>Kitchen</option>
<option>Bathroom</option>
<option>Basement</option>
<option>Full Home Renovation</option>
<option>New Construction (Home)</option>
<option>Commercial Reno (Outdoor)</option>
<option>Commercial Reno (Indoor)</option>
<option>Commercial Const. New</option>
</select>
</span></div>
<div class="row">
<span class="label">Other</span><span class="formw"><input id="Other" type="text" size="22" /></span>
</div>
<div class="row">
<span class="label">Deadline Date</span><span class="formw"><input id="Deadline Date" type="text" size="22" /></span>
</div>
<div class="row">
<span class="label">Budget</span><span class="formw"><input id="Budget" type="text" size="22" /></span>
</div>
<div class="row">
<span class="label">Message</span><span class="formw"><textarea cols="20" rows="8" class="formw">
</textarea>
</span>
</div>
<div class="row">
<span class="formw"><input name="Submit" type="submit" id="Submit" onclick="MM_validateForm('First Name','','R');MM_validateForm('Last Name','','R');MM_validateForm('Email Address','','RisEmail');return document.MM_returnValue" value="Submit" />
<input type="reset" name="Reset Form" id="Reset Form" value="Reset" />
</span></div>
</form>


It works, validates and sends me the email.

But I'm only getting this, it's correct only one field though and the Submit...


Select: --Select--

Submit: Submit

Your suggestions are always appreciated.
__________________
Best regards,
Marc
marcman is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-08-2009, 09:24 PM   #2 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Your HTML looks fine,

but you need to show us the PHP script as well.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is online now  
Add Post to del.icio.us
Reply With Quote
Old 07-08-2009, 10:01 PM   #3 (permalink)
Junior Member
 
Join Date: 07-08-09
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

marcman is liked by many
Here it is...
Code:
<?php $my_email = "mmantha@rogers.com"; $errors = array(); // Remove $_COOKIE elements from $_REQUEST. if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}} // Check all fields for an email header. function recursive_array_check_header($element_value) { global $set; if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i",$element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);} } } recursive_array_check_header($_REQUEST); if($set){$errors[] = "You cannot send an email header";} unset($set); // Validate email field. if(isset($_REQUEST['email']) && !empty($_REQUEST['email'])) { if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";} $_REQUEST['email'] = trim($_REQUEST['email']); if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}} } // Check referrer is from same site. if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";} // Check for a blank form. function recursive_array_check_blank($element_value) { global $set; if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}} else { foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);} } } recursive_array_check_blank($_REQUEST); if(!$set){$errors[] = "You cannot send a blank form";} unset($set); // Display any errors and exit if errors exist. if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;} if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");} // Build message. function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");} $message = build_message($_REQUEST); $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL.""; $message = stripslashes($message); $subject = "Lianos Interiors Inquiry"; $headers = "From: " . $_REQUEST['email']; mail($my_email,$subject,$message,$headers); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Lianos Interiors</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> <!-- .style1 {font-family: Arial, Helvetica, sans-serif} body { margin-top: 20px; } .style2 {font-family: Arial, Helvetica, sans-serif; color: #666666; } --> </style> </head> <body bgcolor="#ffffff" text="#000000"> <div> <center> <p class="style2">Thank you, your message has been sent</p> <p class="style2">We'll respond very soon.</p> <p><span class="style1"><a href="<?php print $continue; ?>">Click here to continue</a></span></p> <p><a href="index.html"><img src="images2/lianos-interiors-will-get-back-to-you.jpg" width="600" height="234" border="0"></a></p> </center> </div> </body> </html>
__________________
Best regards,
Marc

Last edited by htmlbasictutor; 07-08-2009 at 11:23 PM..
marcman is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Email form help chuco61 Coding Forum 5 12-17-2008 11:52 AM
[WTS] Form to Email script - ASP searchbliss Content 0 11-13-2008 01:45 PM
Why won't my php form email results? watley Coding Forum 5 10-26-2007 08:36 AM
PHP: Email form Optix Coding Forum 20 04-13-2007 06:04 PM
EMAIL FORM Rossco Web Design Lobby 3 10-29-2006 10:07 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 07:45 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.