I have a PHP mail form and I'm trying to get it to send a certain way. Here is my PHP code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$tel2 = $_POST['tel2'];
$tel3 = $_POST['tel3'];
$message = $_POST['message'];
$message = wordwrap($message, 70, "\r\n");
$mail_to = '
mye...@mydomain.com';
$subject = 'Message from site visitor, '.$name;
$body_message = 'From: '.$name."\n";
$body_message .= 'Email: '.$email."\n";
$body_message .= 'Phone number: '.$tel . $tel2 . $tel3."\n";
$body_message .= 'Message: '.$message;
$headers = 'From: '.$email."\r\n";
$headers .= 'Reply-To: '.$email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
// alert('Thank you for contacting us. We will get back to you shortly.');
window.location = 'thankyou.php';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
// alert('Message failed. Please, send an email to
mye...@mydomain.com');
window.location = 'mailerror.php';
</script>
<?php
}
?>
What I'm trying to do is have the phone number sent from the form's 3 phone number input fields in this format:
(123) 456-7890
How do I put the parentheses and hyphen in the PHP code without getting a T_CONSTANT_ENCAPSED_STRING error?