Send.php not showing content of the forms - php

so i finally got my feedback form to be working and sending emails to my email address but i have another problem. The content of the forms are not showing, don't know what is wrong. I'm new to php tho so i'm very sure its simple.. posted the code below
<?php
$name = $_POST ['name'];
$mail = $_POST ['mail'];
$number = $_POST ['number'];
$feedback = $_POST ['feedback'];
$to = 'ATotallyRandom#Email.net';
$subject = 'Feedback from atetaconsult.com';
$msg = "Your name: $name\n" .
" Your email: $email\n" .
" Feedback: $feedback\n";
mail ($to, $subject, $msg, 'From:' . $email);
echo ' thank you <br/>';
echo ' your name ' .$name .'<br/>';
echo ' Your email ' . $email .'<br/>';
echo ' Your feedback ' . $feedback . '<br/>';
?>
The HTML code for the form is below too
<form method="post" action="send.php">
<p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;">
We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p>
<div class="row form">
<input id="name" class="name" type="text" placeholder="Name">
<input id="mail" class="mail" type="text" placeholder="Email">
<input id="number" class="phone" type="text" placeholder="Phone">
</div>
<div class="span6 box box_r">
<textarea id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea>
</div>
<div class="btn" style="margin-top:5px;">
<input type="submit" value="Send your message">
</div>
</form><div style="clear: both;"></div>

Here:
$msg = "Your name: $name\n" .
" Your email: $email\n" .
" Feedback: $feedback\n";
you are asking for the variable $email
but you have specified it as $mail at the top.
See: http://markpetherbridge.co.uk/StackOverflow/phpmail.php?name=Mark&mail=test#test.com&feedback=testfeedback
I have changed it to $email and the type to $_GET for demonstration purposes, but it seems to be working. Try that.
Here is the Full code for the file:
<?php
$name = $_GET ['name'];
$email = $_GET ['mail'];
$number = $_GET ['number'];
$feedback = $_GET ['feedback'];
$to = 'ATotallyRandom#Email.net';
$subject = 'Test from Mark P';
$msg = "Your name: $name\n";
$msg .= " Your email: $email\n";
$msg .= " Feedback: $feedback\n";
mail ($to, $subject, $msg, 'From:' . $email);
echo ' thank you <br/>';
echo ' your name ' .$name .'<br/>';
echo ' Your email ' . $email .'<br/>';
echo ' Your feedback ' . $feedback . '<br/>';
?>
<br /><br />
Here is the result from $msg: <br /><br />
<?php
echo $msg;
?>
You need to add name into your html:
<input name="name" id="name" class="name" type="text" placeholder="Name">
<input name="mail" id="mail" class="mail" type="text" placeholder="Email">
<input name="number" id="number" class="phone" type="text" placeholder="Phone">

Put all these code in between:
if($_POST){
// Your coding
}
Also show me the Javascript/Jquery coding you are using on contact form.

You haven't set a name value on the input.
Change in:
<form method="post" action="send.php">
<p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;">
We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p>
<div class="row form">
<input name="name" id="name" class="name" type="text" placeholder="Name">
<input name="mail" id="mail" class="mail" type="text" placeholder="Email">
<input name="number" id="number" class="phone" type="text" placeholder="Phone">
</div>
<div class="span6 box box_r">
<textarea name="feedback" id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea>
</div>
<div class="btn" style="margin-top:5px;">
<input type="submit" value="Send your message">
</div>
</form><div style="clear: both;"></div>

Related

Form validation - required fields in php form

I've found a form that works well with multiple file uploads and am trying to work in some validation, i'm just trying to make some fields required for now.
Currently some validation is occuring with error messages however the form always posts regardless. My php knowledge is limited and it may look messy but I would be grateful if anybody could help me as to how to amend the following code..
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// we'll begin by assigning the To address and message subject
$to="paul#thedesignbank.co.uk";
$subject="Parts Request";
$subject = trim($_POST['namefrom']);
$vehiclereg = trim($_POST['vehiclereg']);
$chassisnumber = trim($_POST['chassisnumber']);
$contactnumber = trim($_POST['contactnumber']);
$emailfrom = trim($_POST['emailfrom']);
$address = trim($_POST['address']);
$town = trim($_POST['town']);
$postcode = trim($_POST['postcode']);
$comments = trim($_POST['comments']);
// get the sender's name and email address
// we'll just plug them a variable to be used later$from = stripslashes($_POST['fromname'])." <".stripslashes($_POST['fromemail']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// now we'll build the message headers
$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
// here, we'll start the message body.
// this is the text that will be displayed
// in the e-mail
$message.="From: ".$subject."\n";
$message.="Email: ".$emailfrom."\n";
$message.="Vehicle Registration: ".$vehiclereg."\n";
$message.="Chassis Number: ".$chassisnumber."\n";
$message.="Address: ".$address."\n";
$message.="Town: ".$town."\n";
$message.="Postcode: ".$postcode."\n";
$message.="Contact Number: ".$contactnumber."\n";
$message.="Comment: ".$comments."\n\n";
//my validation gives a message but email still posts
$errors = array();
if (!$_POST['namefrom'])
// if not, add that error to our array
$errors[] = "Name is required";
// check to see if a subject was entered
if (!$_POST['emailfrom'])
// if not, add that error to our array
$errors[] = "Email Address is required";
if (!$_POST['contactnumber'])
// if not, add that error to our array
$errors[] = "Contact Number is required";
// check to see if a message was entered
if (!$_POST['vehiclereg'])
// if not, add that error to our array
$errors[] = "vehiclereg is required";
// if there are any errors, display them
if (count($errors)>0){
echo "<strong>ERROR:<br>\n";
foreach($errors as $err)
echo "$err<br>\n";
} else {
}
// next, we'll build the invisible portion of the message body
// note that we insert two dashes in front of the MIME boundary
// when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll process our uploaded files
foreach($_FILES as $userfile){
// store the file information to variables for easier access
$tmp_name = $userfile['tmp_name'];
$type = $userfile['type'];
$name = $userfile['name'];
$size = $userfile['size'];
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content.
// NOTE: we don't set another boundary to indicate that the end of the
// file has been reached here. we only want one boundary between each file
// we'll add the final one after the loop finishes.
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n";
}
}
// here's our closing mime boundary that indicates the last of the message
$message.="--{$mime_boundary}--\n";
// now we just send the message
if (#mail($to, $subject, $message, $headers))
echo "Message Sent Successfully";
else
echo "Failed to send";
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
enctype="multipart/form-data" name="form1">
<h3>Vehicle Details</h3>
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">Vehicle Registration: <span style="color:red">*</span></label>
<input class="form-input" name="vehiclereg" id="vehiclereg" type="text" tabindex="1" style="width:100%;"/></p>
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">VIN/Chassis Number (Last 6 Digits):</label>
<input class="form-input" name="chassisnumber" id="chassisnumber" type="text" tabindex="1" style="width:100%;"/></p>
<h3>Customer Details</h3>
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">Name: <span style="color:red">*</span></label>
<input class="form-input" name="namefrom" id="namefrom" type="text" tabindex="1" style="width:100%;"/></p>
<!--changed these-->
<p style="margin:17px 0"><label style=" font-family: Helvetica, Arial, sans-serif;">Address:</label>
<input class="form-input" name="address" id="address" type="text" tabindex="1" style="width:100%;"/></p>
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">Town:</label>
<input class="form-input" name="town" id="town" type="text" tabindex="1" style="width:100%;"/></p>
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">Postcode:</label>
<input class="form-input" name="postcode" id="postcode" type="text" tabindex="1" style="width:100%;"/></p>
<!--changed these-->
<p style="margin:17px 0"> <label style=" font-family: Helvetica, Arial, sans-serif;">Email: <span style="color:red">*</span></label>
<input class="form-input" name="emailfrom" id="emailfrom" type="text" tabindex="3" style="width:100%;"/></p>
<p style="margin:17px 0"> <label style="margin-right: 4px; font-family: Helvetica, Arial, sans-serif;">Contact No: <span style="color:red">*</span></label>
<input type="text" class="form-input" name="contactnumber" id="contactnumber" rows="2" cols="22" tabindex="6" style="width:100%;" /></p>
<p style="margin:17px 0"> <label style="margin-right: 4px; vertical-align:top; font-family: Helvetica, Arial, sans-serif; ">Brief Description of Request: </label>
<textarea class="form-input" name="comments" id="comments" rows="7" cols="22" tabindex="6" style="height:50px; width:100%;" ></textarea></p>
<p style="margin:17px 0">
<label style="margin-right: 4px; font-family: Helvetica, Arial, sans-serif;">Vehicle image/doc one:</label>
<input type="file" name="file1">
</p>
<p style="margin:17px 0">
<label style="margin-right: 4px; font-family: Helvetica, Arial, sans-serif;">Vehicle image/doc two:</label>
<input type="file" name="file2">
</p>
<p style="margin:17px 0">
<label style="margin-right: 4px; font-family: Helvetica, Arial, sans-serif;">Vehicle image/doc three:</label>
<input type="file" name="file3">
</p>
<div style="clear:both">
<p> I would like to subscribe to the newsletter
<input name="subscribe" type="checkbox" value="website_subscribers" name="mailinglist[]" checked="checked" /></p>
</div>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
<?php } ?>
Using if (!$_POST['emailfrom']) will only check if the posted field exists. Regardless if it's empty or not.
Instead you could use empty:
if (empty($_POST['emailfrom'])) {
echo 'error'
}
You also can add some additional checks to the fields like a valid email check or phonenumber validator:
if (empty($_POST['emailfrom']) || !isValidEmailCustomFunction($_POST['emailfrom]')) {
echo 'error'
}
something like
if(!isset($_POST['namefrom']) || $_POST['namefrom']=="" ){
$error[]="Please enter your name";
}

php values are not printing

I'm trying to complete a task. for which i need to print $message(specified below). But its not printing i don't know what seems to be the problem. i thanks for your help in advance... and i don't wanna do this echo $message thing in the html code..and one thing you should know that the values are printing before echo $message. the php variables have values in them before the echo $message, but these same variables print nothing when i echo $message.. it only prints
Customer Name:
Customer Email:
Customer Mobile:
Customer City:
Customer Billing Address:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo $message="
<html><head> </head>
<body>
Customer Name: <?php echo $name; ?>
<br>
Customer Email: <?php echo $email; ?>
<br>
Customer Mobile: <?php echo $mobile; ?>
<br>
Customer City: <?php echo $city; ?>
<br>
Customer Billing Address: <?php echo .$bill_add; ?>
</body></html>";}
?>
HTML file:
<html>
<body>
<form id="contact_form" action="#" method="POST"
enctype="multipart/form-data" style=" padding-left: 121px;">
<div class="row">
<label for="name" style=" margin-left: 9px;">Your name:</label><br />
<input id="name" class="input" name="name" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">Your email:</label><br
/>
<input id="email" class="input" name="email" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">Mobile #:</label><br />
<input id="email" class="input" name="mobile" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="email" style=" margin-left: 9px;">City:</label><br />
<input id="email" class="input" name="city" type="text" value=""
size="30" required/><br />
</div>
</br>
<div class="row">
<label for="message" style=" margin-left: 9px;">Shipping Address:
</label><br />
<textarea id="message" class="input" name="message" rows="7" cols="32"
required></textarea><br />
</div>
</br>
<div class="row">
<input name="sub" id="submit_button" type="submit" value="Order Proceed
Now" style="margin-top: 120px;background-color: green;padding:10px;
color:#FFF; "/>
</div>
</br>
</form>
</body>
</html>
change your $message to :
echo $message="
<html><head> </head>
<body>
Customer Name: $name
<br>
Customer Email: $email
<br>
Customer Mobile: $mobile
<br>
Customer City: $city
<br>
Customer Billing Address: $bill_add
</body></html>";}
?>
The problem was that you were using <?php echo into a <?php echo
Try:
<?php
if(isset($_POST['sub'])){
$name=$_POST['name'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$city=$_POST['city'];
$bill_add=$_POST['message'];
echo "
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";}
?>
You cant use
so better use it like, Using concatenation in php solves your problem.
<?php
echo $message="
<html><head> </head>
<body>
Customer Name: ".$name."
<br>
Customer Email: ".$email."
<br>
Customer Mobile: ".$mobile."
<br>
Customer City: ".$city."
<br>
Customer Billing Address: ".$bill_add."
</body></html>";
?>
<?php echo $message="<html><head> </head><body>Customer Name: " . $name . " <br>Customer Email: " . $email . " <br>Customer Mobile: " . $mobile . " <br>Customer City: " . $city . "<br>Customer Billing Address: " . $bill_add . " </body></html>";?>
// we are using concatenation here ( . ) so we don't need to write and remove spaces.

PHP not working correctly?

I have this PHP code here, which should sent the Names, Email and comment of the user to an email. Although it doesn't seem to be working any more. I've been using this code as a basis for my contact form for many years. Now they're just not working.
Your message is being sent...
<?php
$emailSubject = 'A message from: '.$_POST['name'] .' '.'-'.' ' .'Email Adress: ' .$_POST['email'];
$webMaster = 'webmaster#gmail.com';
$name1 = $_POST['name1'];
$name2 = $_POST['name2'];
$email = $_POST['email'];
$sub = $_POST['sub'];
$comments = $_POST['comments'];
$body = <<<EOD
<br><hr><br>
<b>First Name: $name1 </b><br>
<b>Last Name: $name2 </b><br>
Email: $email <br>
Subject: $sub <br>
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
$theResults = <<<EOD
<html>
<head>
<title>Your message is being sent...</title>
<meta http-equiv="refresh" content="4;URL=http://www.google.co.uk">
<style type="text/css">
<!--
body {
background-color: #25EA5F;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #30489E;
text-decoration: none;
padding-top: 350px;
margin-left: 550px;
width: 800px;
}
-->
</style>
</head>
</html>
</body>
EOD;
echo "$theResults";
?>
It's very confusing and annoying. Messages when sent to Hotmail don't even appear, so that'll force the clients to get a new email because of it, and when sent to Google... Does it not accept $_POST or something?
As you can see, the SCRIPT does work, it's just with G-mail none of the important information seems to show up, and on Hotmail the messages don't even send/appear!! Thanks for your help. Here is the HTML if needed.
<div class="contactwrap">
<div class="ContactInner">
<div class="ContactTitle">CONTACT US</div>
<form action="Scripts/contact.php" method="post">
<div class="containboxes">
<span id="sprytextfield1">
<label for="text1"></label>
<input name="text1" type="text" class="inputstyle" id="name1" value="First Name" size="5" maxlength="5" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield2">
<label for="text2"></label>
<input name="text2" type="text" class="inputright" id="name2" value="Last Name" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield3">
<label for="text3"></label>
<input name="text3" type="text" class="inputstyleBelow" id="email" value="E-mail Address" />
<span class="textfieldRequiredMsg"></span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>
<span id="sprytextfield4">
<label for="text4"></label>
<input name="text4" type="text" class="inputrightBelow" id="sub" value="Message Subject" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextarea1">
<label for="textarea1"></label>
<textarea name="textarea1" cols="45" rows="5" class="inputstyleMsg" id="comments">Message Here</textarea>
<span id="countsprytextarea1"> </span><span class="textareaRequiredMsg"></span> <span class="textareaMinCharsMsg">Minimum number of characters not met.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span>
<div class="sendbtn"><input name="Submit message" type="submit" class="submitmail" value="" /></div>
</div>
</form>
</div>
</div>
Your form fields are incorrect. id is NOT used in form submission. the name parameter is. Since you've named your form fields as text1, text2, etc... but are looking for name1 and similar in your PHP code, you're trying to retrieve non-existent fields.
e.g. you have:
<input name="text1" type="text" class="inputstyle" id="name1" value="First Name" size="5" maxlength="5" />
$_POST['name1'];
no, that field will actually be $_POST['text1'].

intermittent duplicate emails from php contact form

First time posting here. I have a php contact form on a CMS site that is sending me duplicate emails. The problem is intermittent. Sometimes it send two copies, sometimes it sends as many as 8 copies. Sometimes it works normally. The issue started after removing some fields from the form.
The form submits to a separate page that sends the email to 3 recipients. This page also serves as a thank you page that displays the information submitted by the user. "Thanks for contacting us the following information has been received".
The embeds are expresionengine code. Thanks for your help!!!
Here is the form:
<form id="Form1" name="Form1" method="post" action="http://myprocessingpage.com">
<label for="fname">Name:</label> <input type="text" size="42" id="fname" name="fname"><br>
<label for="email">Email Address:</label> <input size="42" type="text" id="email" name="email"><br>
<label for="telephone">Telephone:</label> <input size="42" type="text" id="telephone" name="telephone"><br>
<br>
<div style="float: left; margin-right: 20px; margin-bottom: 30px;">
<label>How did you hear about us?</label> <br>
<input type="hidden" id="arrayfix" name="how[]" value="">
<input type="checkbox" id="website" name="how[]" value="website"> Website<br>
<input type="checkbox" id="referral" name="how[]" value="referral"> Referral<br>
<input type="checkbox" id="tradeshow" name="how[]" value="tradeshow"> Tradeshow<br>
</div>
<div style="float: left; margin-bottom: 30px;">
<label >Shelter Type:</label><br>
<input type="hidden" id="arrayfix2" name="type[]" value="">
<input type="checkbox" id="safe4x6" name="type[]" value="Safe_Room_4X6"> 4'X6' Shelter<br>
<input type="checkbox" id="safe4x8" name="type[]" value="Safe_Room_4X8"> 4'X8' Shelter<br>
<input type="checkbox" id="custom" name="type[]" value="Custom_Size_Safe_Room"> Custom Size Shelter<br>
</div>
<div style="clear: both;"></div>
<label for="question"> Questions or Comments:</label><br> <textarea rows="7" maxlength="500" name="question" id="question" cols="50"></textarea><br>
<br>
<input type="submit" class="btnimage" id="submit" name="submit" value="">
</form>
Here is the processing page (http://myprocessingpage.com):
<?php
if (isset($_POST['fname']))
{
?>
<!DOCTYPE html>
<head>
<title>Thank you for contacting us!</title>
{embed="page/headtags"}
</head>
<body>
{embed="page/header"}
{embed="page/drop"}
<div id="contentbg">
<div id="content">
<?php
$name = $_POST['fname'];
$telephone = $_POST['telephone'];
$email = $_POST['email'];
$question = $_POST['question'];
$howarray = $_POST['how'];
$howimplode = implode("\n", $howarray);
$how = str_replace("_", " ", "$howimplode");
$typearray = $_POST['type'];
$typeimplode = implode("\n", $typearray);
$type = str_replace("_", " ", "$typeimplode");
//sent to us
$to = "mail1#mail.com, mail2#mail.com, mail3#mail.com";
$subject = "Info Request";
$message = "INFO REQUEST:\n\nName: $name\n\nEmail: $email\n\nTelephone: $telephone\n\nHow they heard about us:\n$how\n\nShelter type:\n$type\n\nQuestions or Comments:\n$question";
$from = "info#mysite.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
?>
<div id="form">
<p style="margin-top: 0px; margin-bottom: 40px; color: green; font-weight: bold;">Thank you for contacting us! The following information has been received:</p>
<div style="margin-left: 30px;">
<?php
echo "<p><b>Name:</b> ".$name."</p>";
echo "<p><b>Email:</b> ".$email."</p>";
echo "<p><b>Telephone:</b> ".$telephone."</p>";
$thankshowimplode = implode("</br>", $howarray);
$thankshow = str_replace("_", " ", "$thankshowimplode");
$thankstypeimplode = implode("</br>", $typearray);
$thankstype = str_replace("_", " ", "$thankstypeimplode");
echo "<p><b>How you heard about us:</b></br> ".$thankshow."</p>";
echo "<p><b>Type of shelter(s):</b></br> ".$thankstype."</p>";
echo "<p style='word-wrap:break-word;'><b>Questions or Comments:</b> ".$question."</p>";
?>
</div>
</div>
</div>
{embed="page/footer"}
</body>
</html>
<?php
}
else
{
?>
<script type="text/javascript">
window.location = 'http://mycontactpage.com';
</script>
<?php
}
?>
If someone double-clicks (or clicks it 8 times) your submit button, your script could be run more than once. Try disabling the submit button on click (using Javascript).
Another, probably unnecessary, solution would be to lock your form script (e.g. using semaphores), create a database entry with the provided info, then check to see if you've sent the same info recently (e.g. within the last five minutes), and don't sent it again if you have.
I'm sure the Javscript disable functionality will suffice :)
Or, if you want to find out what's really going on, you could just create a log file that logs "sent [some distinct piece of data that might tell these posts apart] at [timestamp]". If you see a couple of these, with the same [distinct info] entry and really close timestamp, then your problem is multiple clicks to the submit button.

PHP mail form - only one variable not submitting

I have set up a PHP mail form set up that only correctly outputs some of the variables entered in the form. It DOES mail the $name and $email variables, but not the $message variable.
The php to send the form is here:
<?php
if($_SERVER["REQUEST_METHOD"] == "POST" ){
$name = trim($_POST["name"]);
$email = trim($_POST["email"]);
$message = trim($_POST["message"]);
//sending email
require_once("siteIncludes/class.phpmailer.php");
$mail = new PHPMailer();
$email_body = "";
$email_body = $email_body . "Name: " . $name . $message . "<br />";
$email_body = $email_body . "Email: " . $email . "<br />";
$email_body = $email_body . "Message: " . $message;
$mail->SetFrom("$email,$name");
$address = "foo#bar.com";
$mail->AddAddress($address);
$mail->Subject = "Form Submission | ".$name;
$mail->MsgHTML($email_body);
if(!$mail->Send() ){
echo 'There was a problem sending the email: '.$mail->ErrorInfo;
exit();
}
header("Location: myContact.php?status=thanks");
exit();
};
?>
And the HTML that sets up the form is here:
<div id="contactFormWrap" class="span6 offset3">
<form method="post" action="myContact.php" id="contactForm">
<div>
<label for="name">Please leave your name</label>
<input type="text" name="name" id="name" value="" class="required" />
</div>
<div>
<label for="email">and your email</label>
<input type="text" name="email" id="email" value="" class="required email" />
</div>
<div>
<label for="subject">What is your message about?</label>
<input type="text" name="subject" id="subject" value="" class="required" />
</div> -->
<div>
<label for="message">and your message</label>
<textarea name="message" id="message" value="" rows="10" class="required"></textarea>
</div>
<div id="messageButtons">
<input type="submit" value="Submit" name="contactSubmit" id="contactSubmit" class="sendEmail btn" />
</div>
</form>
</div>
I hope that was enough information. Does anyone know why the $message variable isn't being output to the submitted email?
thanks
I think this is your problem:
value=""
The <textarea> tag does not have a value attribute, however different browsers have different ways of handling invalid code, so whatever browser you are using must be using the value found in this invalid attribute instead of what you type in the actual text box.
Just do:
<textarea name="message" id="message" rows="10" class="required"></textarea>

Categories