Something very strange going with my contact form..
When submitting via the actual page.. www.mydomain.com/mail.php it submits fine, send the email enquiry works as it should.
However, when its included on the contact page with the following..
<?php include('mail.php'); ?>
It sends the email twice, or sometimes not at all!
Any ideas?
<?php
if (isset($_POST["mail"]) && ($_POST["mail"]=="send")) {
//ini_set("sendmail_from", "mailserver#thedomain.com");
/******** START OF CONFIG SECTION *******/
//$sendto = "enquiries#rivelintravel.co.uk";
$sendto = "test#thedomain.com";
$subject = "Website Form Test";
$errorImage = "assets/form/exclamation.png";
$acceptImage = "assets/form/accept.png";
/******** END OF CONFIG SECTION *******/
$SpamReplaceText = "*content removed*";
// Error message prited if spam form attack found
$SpamErrorMessage = "<div class=\"contactFormErrorMessage\">Malicious code content detected.<br>Your IP Number of ".getenv("REMOTE_ADDR")." has been logged.</div>";
foreach($_POST as $key => $value) {
$post[$key] = $value;
}
$name = $post['name'];
$email = $post['email'];
// $message = $post['message'];
$headers = "From: $email\n";
$headers . "MIME-Version: 1.0\n"
. "Content-Transfer-Encoding: 7bit\n"
. "Content-type: text/html; charset = \"iso-8859-1\";\n\n";
// Check for Website URL's in the form input boxes as if we block website URLs from the form,
// then this will stop the spammers wastignt ime sending emails
foreach($post as $key => $value) {
if (preg_match("/http/i", "$post[$key]")) {echo "$SpamErrorMessage"; exit();}
}
// Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer
$pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string
foreach($post as $key => $value) {
$post[$key] = preg_replace($pattern, "", $value);
}
// Check for the injected headers from the spammer attempt
// This will replace the injection attempt text with the string you have set in the above config section
$find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
foreach($post as $key => $value) {
$post[$key] = preg_replace($find, "$SpamReplaceText", $value);
}
// Check to see if the fields contain any content we want to ban
foreach($post as $key => $value) {
if(stristr($post[$key], $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
}
// Do a check on the send email and subject text
foreach($post as $key => $value) {
if(stristr($post[$key], $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();}
}
// Build the email body text
$emailcontent = "Website Form Test" . "\n";
$emailcontent .= "_" . "\n";
$emailcontent .= "Name: " . $_POST['name'] . "\n";
$emailcontent .= "Email: " . $_POST['email'] . "\n";
$emailcontent .= "Telephone Number: " . $_POST['tel'] . "\n";
$emailcontent .= "_" . "\n";
// Check the email address enmtered matches the standard email address format
if (!eregi("^[A-Z0-9._%-]+#[A-Z0-9._%-]+\.[A-Z]{2,6}$", $post['email'])) {
echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>It appears you entered an invalid email address</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>";
}
elseif (!trim($post['name'])) {
echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>Please go back and enter a Name</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>";
}
elseif (!trim($post['email'])) {
echo "<div class=\"contactFormErrorMessage\"><img src=\"$errorImage\" alt=\"Error\" /><p>Please go back and enter an Email</p><p><a href='javascript: history.go(-1)'>Click here to go back</a></p></div>";
}
// Sends out the email or will output the error message
elseif (mail($sendto, $subject, $emailcontent, $headers)) {
echo "<div class=\"contactFormSuccessMessage\"><img src=\"$acceptImage\" alt=\"Success\" /><p>Thank You $name<br />We will be in touch as soon as possible.</p></div>";
}
}else{
?>
<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" id="contactForm" name="contactForm">
<input name="mail" type="hidden" value="send"/>
<div class="content clearfix">
<div class="left">
<h3>Personel Details: </h3>
<div class="field">
<label for="name">Name <span class="required" title="This field is required.">*</span></label>
<input name="name" type="text" />
</div>
<div class="field">
<label for="email">Email Address<span class="required" title="This field is required.">*</span></label>
<input name="email" type="text" />
</div>
<div class="field">
<label for="tel">Contact Number</label>
<input name="tel" type="text" />
</div>
</div>
<!--column1-->
<div id="sub" class="field">
<label for="submit"> </label>
<input class="submit" type="submit" name="submit" value="submit" id"submit" />
</div>
</div>
</div><!--column-->
</fieldset>
</form>
<?php } ?>
Related
This question already has answers here:
PHP mail does not get sent, how do I debug? [duplicate]
(2 answers)
Closed 4 months ago.
So this contact form used to work, however now it loads and says mail sent when someone clicks submit but I never get any emails, what am I missing out?
<?php
// Replace this with your own email address
$siteOwnersEmail = 'email#domain.com';
if($_POST) {
$name = trim(stripslashes($_POST['contactName']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check Name
if (strlen($name) < 2) {
$error['name'] = "Please enter your name.";
}
// Check Email
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+#[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address.";
}
// Check Message
if (strlen($contact_message) < 15) {
$error['message'] = "Please enter your message. It should have at least 15 characters.";
}
// Subject
if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Message
$message .= "Email from: " . $name . "<br />";
$message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!$error) {
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
if ($mail) { echo "OK"; }
else { echo "Something went wrong. Please try again."; }
} # end if - no validation error
else {
$response = (isset($error['name'])) ? $error['name'] . "<br /> \n" : null;
$response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
$response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
echo $response;
} # end if - there was a validation error
}
?>
And this is the contact form:
<form name="contactForm" id="contactForm" method="post" action="mail/mail.php">
<fieldset>
<div class="form-field">
<input name="contactName" type="text" id="contactName" placeholder="Name" value="" minlength="2" required="">
</div>
<div class="form-field">
<input name="contactEmail" type="email" id="contactEmail" placeholder="Email" value="" required="">
</div>
<div class="form-field">
<input name="contactSubject" type="text" id="contactSubject" placeholder="Subject" value="">
</div>
<div class="form-field">
<textarea name="contactMessage" id="contactMessage" placeholder="message" rows="10" cols="50" required=""></textarea>
</div>
<div class="form-field">
<button type="submit" name="submit" value="send"class="submitform">Submit</button>
<div id="submit-loader">
<div class="text-loader">Sending...</div>
<div class="s-loader">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
</div>
</div>
</fieldset>
</form>
All the messages work, am I missing out on some SMPT information or something? Are there any alternatives to using phpmailer for this job?
For sending mail u need to use any of the mail service provider.
Well for mail to work your server has to have a correct configuration. Since I suspect this is a local environment I doubt it is. You best shot is using a mail library or a mail api service.
Most common php library for mailing with smtp authentication is probably
https://github.com/PHPMailer/PHPMailer
For api mail services I recommend searching on google there are plenty of alternatives
When i am replacing the email with my email id, it shows "?ok" and if i am leaving it default it shows "Your emails was Sent Successfully"
i guess there is something wrong with php code, when i edit it shows "?ok", and when i reset it back it agains shows "?ok" until i don't upload the original file which i edited (it has same code, just not opened or edited)
Here is my Php code:
<?php
// Replace this with your own email address
$siteOwnersEmail = 'user#website.com';
if($_POST) {
$name = trim(stripslashes($_POST['contactName']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check Name
if (strlen($name) < 2) {
$error['name'] = "Please enter your name.";
}
// Check Email
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+#[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address.";
}
// Check Message
if (strlen($contact_message) < 15) {
$error['message'] = "Please enter your message. It should have at least 15 characters.";
}
// Subject
if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Message
$message .= "Email from: " . $name . "<br />";
$message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!$error) {
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
if ($mail) { echo "OK"; }
else { echo "Something went wrong. Please try again."; }
} # end if - no validation error
else {
$response = (isset($error['name'])) ? $error['name'] . "<br /> \n" : null;
$response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
$response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
echo $response;
} # end if - there was a validation error
}
?>
HTML CODE:
<div class="contact-primary">
<h3 class="h6">Send Us A Message</h3>
<form name="contactForm" id="contactForm" method="post" action="" novalidate="novalidate">
<fieldset>
<div class="form-field">
<input name="contactName" type="text" id="contactName" placeholder="Your Name" value="" minlength="2" required="" aria-required="true" class="full-width">
</div>
<div class="form-field">
<input name="contactEmail" type="email" id="contactEmail" placeholder="Your Email" value="" required="" aria-required="true" class="full-width">
</div>
<div class="form-field">
<input name="contactSubject" type="text" id="contactSubject" placeholder="Subject" value="" class="full-width">
</div>
<div class="form-field">
<textarea name="contactMessage" id="contactMessage" placeholder="Write us a summary for your business and what we can do to help" rows="10" cols="50" required="" aria-required="true" class="full-width"></textarea>
</div>
<div class="form-field">
<button class="full-width btn--primary">Submit</button>
<div class="submit-loader">
<div class="text-loader">Sending...</div>
<div class="s-loader">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
</div>
</div>
</fieldset>
</form>
<!-- contact-warning -->
<div class="message-warning">
Something went wrong. Please try again.
</div>
<!-- contact-success -->
<div class="message-success">
Your message was sent, thank you!<br>
</div>
</div> <!-- end contact-primary -->
Please suggest what are the changes i need to do to make work.
you can check here how error shows https://freesoft64.com/test.html
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
I was working on my own vCard/resume website.
But I am having some trouble with my .php file and contact form.
I tried to debug it but I had no success.
Here is my form in html
<!-- form -->
<form name="contactForm" id="contactForm" method="post" action="inc/sendEmail.php">
<fieldset>
<div class="form-field">
<input name="contactName" type="text" id="contactName" placeholder="Name" value="" minlength="2" required>
</div>
<div class="form-field">
<input name="contactEmail" type="email" id="contactEmail" placeholder="Email" value="" required>
</div>
<div class="form-field">
<input name="contactSubject" type="text" id="contactSubject" placeholder="Subject" value="">
</div>
<div class="form-field">
<textarea name="contactMessage" id="contactMessage" placeholder="Message" rows="10" cols="50" required></textarea>
</div>
<div class="form-field">
<button class="submitform">Submit</button>
<div id="submit-loader">
<div class="text-loader">
Sending...
</div>
<div class="s-loader">
<div class="bounce1">
</div>
<div class="bounce2">
</div>
<div class="bounce3">
</div>
</div>
</div>
</div>
</fieldset>
</form>
<!-- Form End -->
And my php file
<?php
// Replace this with your own email address
$siteOwnersEmail = 'someone#example.com';
if($_POST) {
$name = trim(stripslashes($_POST['contactName']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check Name
if (strlen($name) < 2) {
$error['name'] = "Please enter your name.";
}
// Check Email
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+#[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address.";
}
// Check Message
if (strlen($contact_message) < 15) {
$error['message'] = "Please enter your message. It should have at least 15 characters.";
}
// Subject
if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Message
$message .= "Email from: " . $name . "<br />";
$message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!$error) {
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
if ($mail) { echo "OK"; }
else { echo "Something went wrong. Please try again."; }
} # end if - no validation error
else {
$response = (isset($error['name'])) ? $error['name'] . "<br /> \n" : null;
$response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
$response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
echo $response;
} # end if - there was a validation error
}
?>
Can someone tell me what I am doing wrong here, because it isn't sending any emails.
Please try this
<?php
$message ="";
if(isset($_POST)){
mail(to,subject,message,headers,parameters);
}
?>
You have to declare type of button type="submit" OR type="button"
in this case work with form so you have to add type="submit"
and check user click button or direct access of file you can check !empty($_POST) with if
// Change in your HTML
<button class="submitform">Submit</button>
// to
<button type="submit" class="submitform">Submit</button>
//Change in your PHP
if($_POST)
// to
if(!empty($_POST))
I have been working on a website recently from a website template (Puremedia). The template originally had a working contact form. It consisted of "First name", "last name", "Email" and "Subject". And then of course the message. I have now replaced the "Last name" text-box with a dropdown menu. I have done so by using the html select tags. Now my question is how I would change the php scripting so that instead of sending the message (Contact form) to One predefined email. It can send it to two different email adresses. How I would like it to be implemented would be using the dropdown menu. So for example the dropdown menu would be someling along these lines: "Choose Receiver" , "Mail 1" , "Mail 2".
And then also adding a checkbox below the message field that will send a copy to the persons own email address. - Here is my contact form code:
<form name="contactForm" id="contactForm" method="post" action="">
<fieldset>
<div class="row">
<div class="six columns mob-whole">
<label for="contactFname">First Name <span class="required">*</span></label>
<input name="contactFname" type="text" id="contactFname" placeholder="First Name" value="" />
</div>
<div class="six columns mob-whole">
<select name="mailacc">
<option value="1">Send til (Vælg venligst)</option>
<option value="2">Direktør</option>
<option value="3">Bogholder</option>
</select>
</div>
</div>
<div class="row">
<div class="six columns mob-whole">
<label for="contactEmail">Email <span class="required">*</span></label>
<input name="contactEmail" type="text" id="contactEmail" placeholder="Email" value="" />
</div>
<div class="six columns mob-whole">
<label for="contactSubject">Subject</label>
<input name="contactSubject" type="text" id="contactSubject" placeholder="Subject" value="" />
</div>
</div>
<div class="row">
<div class="twelve columns">
<label for="contactMessage">Message <span class="required">*</span></label>
<textarea name="contactMessage" id="contactMessage" placeholder="Your Message" rows="10" cols="50" ></textarea>
</div>
</div>
<div>
<button class="submit full-width">Send Message</button>
<div id="image-loader">
<img src="images/loader.gif" alt="" />
</div>
</div>
</fieldset>
</form> <!-- /contactForm -->
<!-- message box -->
<div id="message-warning"></div>
<div id="message-success">
<i class="fa fa-check"></i>Your message was sent, thank you!<br />
</div>
</div> <!-- /contact-form -->
The PHP part:
<?php
// Replace this with your own email address
$siteOwnersEmail = 'mail#domain.com';
if($_POST) {
$fname = trim(stripslashes($_POST['contactFname']));
$lname = trim(stripslashes($_POST['contactLname']));
$email = trim(stripslashes($_POST['contactEmail']));
$subject = trim(stripslashes($_POST['contactSubject']));
$contact_message = trim(stripslashes($_POST['contactMessage']));
// Check First Name
if (strlen($fname) < 2) {
$error['fname'] = "Please enter your first name.";
}
// Check Last Name
if (strlen($lname) < 2) {
$error['lname'] = "Please enter your last name.";
}
// Check Email
if (!preg_match('/^[a-z0-9&\'\.\-_\+]+#[a-z0-9\-]+\.([a-z0-9\-]+\.)*+[a-z]{2}/is', $email)) {
$error['email'] = "Please enter a valid email address.";
}
// Check Message
if (strlen($contact_message) < 15) {
$error['message'] = "Please enter your message. It should have at least 15 characters.";
}
// Subject
if ($subject == '') { $subject = "Contact Form Submission"; }
// Set Name
$name = $fname . " " . $lname;
// Set Message
$message .= "Email from: " . $name . "<br />";
$message .= "Email address: " . $email . "<br />";
$message .= "Message: <br />";
$message .= $contact_message;
$message .= "<br /> ----- <br /> This email was sent from your site's contact form. <br />";
// Set From: header
$from = $name . " <" . $email . ">";
// Email Headers
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if (!$error) {
ini_set("sendmail_from", $siteOwnersEmail); // for windows server
$mail = mail($siteOwnersEmail, $subject, $message, $headers);
if ($mail) { echo "OK"; }
else { echo "Something went wrong. Please try again."; }
} # end if - no validation error
else {
$response = (isset($error['fname'])) ? $error['fname'] . "<br /> \n" : null;
$response .= (isset($error['lname'])) ? $error['lname'] . "<br /> \n" : null;
$response .= (isset($error['email'])) ? $error['email'] . "<br /> \n" : null;
$response .= (isset($error['message'])) ? $error['message'] . "<br />" : null;
echo $response;
} # end if - there was a validation error
}
?>
below is the php code for my contact form, the website is live at the moment and when i use the form to send a query using the contact us form, not all information gets through:
In the email that i receive, the only information that comes through is $subject and the message ($name would like to move in on $move.\r\n\n";). No other data that the client inputs on the website is listed in the email. I have looked at the code and cant seem to find what is wrong.
I would appreciate any help.
<?php
if(!$_POST) exit;
$to = 'mydomain#email.com';
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'You\'ve been contacted by ' . $name . '.';
$msg = "You have been contacted by $name.\r\n\n";
$msg .= "$comment\r\n\n";
$msg .= "You can contact $name via email, $email.\r\n\n";
$msg = "You can call $name on $phone.\r\n\n";
$msg = "$name has $emp employees and the company name is $comp.\r\n\n";
$msg = "$name would like to move in on $move.\r\n\n";
$msg .= "-------------------------------------------------------------------------------------------\r\n";
if(#mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We will call back to you soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again.</span>";
}
?>
Thanks for the replies and suggestions, below is the HTML for the form:
<div id="map"></div>
<div class="dt-sc-margin50"></div>
<div class="container">
<div class="column dt-sc-three-fourth first">
<div class="hr-title">
<h3>Request A Call Back</h3>
<div class="title-sep">
</div>
</div>
<form method="post" class="dt-sc-contact-form" action="php/send.php" name="frmcontact">
<div class="column dt-sc-one-third first">
<p> <span class="auto-style2">Your Name</span><span> <input type="text" placeholder="Name*" name="txtname" maxlength="25" value="" required /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Your Email Address<span> <input type="email" placeholder="Email*" name="txtemail" value="" required /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Your Contact Number <span> <input type="text" placeholder="Phone" name="txtphone" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third first">
<p><span class="auto-style2">Company Name <span> <input type="text" placeholder="Company Name" name="txtcomp" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">No Of Employees <span> <input type="number" placeholder="No Of Employees" name="txtemp" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Move In Date <span> <input type="date" placeholder="Move In Date" name="txtmove" value="" /> </span> </p>
</div>
<p> <span class="auto-style2">Please describe below what kind of office you are looking for,we will reply to your query on the same day.<textarea placeholder="Message*" name="txtmessage" maxlength "750" required ></textarea> </p>
<p> <input type="submit" value="Send Message" name="submit" /> </p>
</form>
<div id="ajax_contact_msg"></div>
</div>
Update 01/10/15
Hi Guys
I made the changes suggested by Dp and sebastianbrosch. The website is now live again but when i attempt to send the form, it says "the page save failed". Below is the updated php code, the html contact us page file remains the same.
Hi apologies i have pasted the php code, but for some reason, it is not showing up in the post. I will try again.
<?php
if(!$_POST) exit;
$to = 'mydomain#email.com';
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'Office enquiry via domain.com from ' . $name . '.';
$msg = "You have been contacted by ".$name."\r\n\n";
$msg .= "You can contact ".$name." via email, ".$email.".\r\n\n";
$msg .= "You can call ".$name." on ".$phone.".\r\n\n";
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
$msg .= $comment."\r\n\n";
$msg .= "---------------------------------------------------------------\r\n";
if(#mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We have received your query and will be in touch soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again or contact us via live chat.</span>";
}
?>
There are missing the points in front of the = in the following lines
$msg = "You can call $name on $phone.\r\n\n";
$msg = "$name has $emp employees and the company name is $comp.\r\n\n";
$msg = "$name would like to move in on $move.\r\n\n";
Replace with the following lines
$msg .= "You can call $name on $phone.\r\n\n";
$msg .= "$name has $emp employees and the company name is $comp.\r\n\n";
$msg .= "$name would like to move in on $move.\r\n\n";
Your Code :
$msg = "You have been contacted by $name.\r\n\n";
$msg .= "$comment\r\n\n";
$msg .= "You can contact $name via email, $email.\r\n\n";
$msg = "You can call $name on $phone.\r\n\n";
$msg = "$name has $emp employees and the company name is $comp.\r\n\n";
$msg = "$name would like to move in on $move.\r\n\n";
Try The Following :
$msg = "You have been contacted by ".$name."\r\n\n";
$msg .= $comment."\r\n\n";
$msg .= "You can contact ".$name." via email, ".$email.".\r\n\n";
$msg .= "You can call ".$name." on ".$phone.".\r\n\n";
$msg .= "$name has ".$emp." employees and the company name is $comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
I think you had several string concatenation errors according to what you have explained in your question.