<?php 
$your_email ='rates@tmsforyou.com,ceggert@sytekcom.com';//  ceggert@sytekcom.com <<=== update to your email address

session_start();
$errors = '';
$name = '';
$company = '';
$phone1 = '';
$visitor_email = '';
$user_message = '';
$ansday = '';
$hidansday='';
 
 $qnday=rand(1,7);

$hidansday=$qnday+1;
if($hidansday==8) {$hidansday=1;}
$whatday=jddayofweek ( cal_to_jd(CAL_GREGORIAN, 1,$qnday, 2012) , 1 );

if(isset($_POST['submit']))
{
  $name = $_POST['name'];
  $company = $_POST['company'];
  $phone1 = $_POST['phone1'];
  $visitor_email = $_POST['visitor_email'];
  $user_message = $_POST['message'];
  $hiddenansday= $_POST['hidansday'];
  $ansday = $_POST['ansday'];
  
  $dw1=trim(strtolower($ansday));
  $dw2=strtolower(trim(jddayofweek (cal_to_jd(CAL_GREGORIAN, 1,$hiddenansday, 2012) , 1 )));
                
  
  ///------------Do Validations-------------
  
  
  if(empty($name))
  {
    $errors .= "\n First Name is a required field. ";
  }

  
  if( !preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $phone1) ) {
  $errors .= "\n Please enter a valid phone number "; 
  }

  $email = htmlspecialchars($_POST['visitor_email']);
  if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $visitor_email))
  {
    $errors .= "\n E-mail address not valid ";
  }


  if ($dw1!==$dw2)
  {
    $errors .= "\n Please enter valid day for the Security Question";
  }
  
  if(empty($errors))
  {
    //send the email
    $to = $your_email;
    $subject="Contact Form - TMC";
    $from = $visitor_email;
    $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
    
    $body = "A user  $name submitted the contact form:\n".
    "First Name: $name\n".
    "Company: $company\n".
    "Phone: $phone1\n".
    "Email: $visitor_email \n".
    "Message: \n ".
    "$user_message\n".
    "IP: $ip\n";  
    
    $headers = "From: $from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";
    
    mail($to, $subject, $body,$headers);
    
    header('Location: thankyou.html');
  }
}

?>

<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Contact Us - Tacoma Motorfreight Service</title>
    <meta name="description" content="">
    
    <!-- CSS -->
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/custom.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
</head>

<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top blue">
      <div class="container">
        <a class="navbar-brand text-center" href="index.html"><img src="images/logo.png" alt="Tacoma Motorfreight Service| TMS |<br>
 Fast Freight Since 1908" id="Logo"></a>
        <button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#navbarsExample07" aria-controls="navbarsExample07" aria-expanded="false" aria-label="Toggle navigation">
          <i class="fas fa-bars fa-2x"></i>
        </button>
        <div class="collapse navbar-collapse" id="navbarsExample07">
          <ul class="navbar-nav mr-auto">
              <li class="nav-item"><a class="nav-link" href="index.html">Home</a></li>
              <li class="nav-item"><a class="nav-link" href="services.html">Services</a></li>
              <li class="nav-item"><a class="nav-link" href="aboutus.html">About Us</a></li>
              <li class="nav-item"><a class="nav-link" href="careers.html">Careers</a></li>
              <li class="nav-item active"><a class="nav-link" href="contact.php">Contact Us</a></li>
          </ul>
        </div>
      </div>
    </nav>

    <!-- CONTENT START -->
    <section class="content pb-0 mt-lg-4 mt-xl-5">
      <div class="container">
      </div>
    </section>
    <!-- CONTENT END -->

    <!-- FOOTER START -->
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-md-12 mb-4">
					<a href="https://zfrmz.com/zZEg8Um23x6WRD7VodJ0" target="_blank" class="btn btn-warning btn-lg mb-2"><i class="fas fa-chevron-right"></i> Rate Quotes</a><br>
				</div>
				<div class="col-sm-6 col-lg-4">
                    <h5 class="line">Navigation</h5>
                    <nav>
                        <a href="index.html">Home</a>
                        <a href="services.html">Services</a>
                        <a href="aboutus.html">About Us</a>
                        <a href="careers.html">Careers</a>
                        <a href="contact.php">Contact Us</a>
                    </nav>
                    <div class="mt-5">
                        <h5>Business Hours</h5>
                        <p>Monday &ndash; Friday: 6 AM &ndash; 8 PM <br>
                            Saturday &amp; Sunday: By Appointment</p>
                    </div>
                </div>
                <div class="col-sm-6 col-lg-4 mt-5 mt-sm-0">
                     <h5 class="line">Contact Us</h5>
                     <address>
                         <span class="title"><strong>TMS Motorfreight Service</strong></span><br>
                         <em>Headquarters</em> <br>
                         1314 East 26th Street <br>
                         Tacoma, WA 98421 <br>
                         <br>
                         <span><img src="images/phone.png" class="mr-2" alt="White Phone Icon"></span>Tacoma: 253-627-3105 <br>
                         <span><img src="images/phone.png" class="mr-2" alt="White Phone Icon"></span>Seattle: 206-622-3105 <br>
                         <span><img src="images/phone.png" class="mr-2" alt="White Phone Icon"></span>Toll Free: 800-228-2829 <br>
                         <span><img src="images/fax.png" class="mr-2" alt="White Printer Icon"></span>Fax: 253-627-0416 <br>
                         <span><img src="images/email.png" class="mr-2" alt="White Envelope Icon"></span><a href="mailto:rates@tmsforyou.com">rates@tmsforyou.com</a>
                     </address>
                </div>
                <div class="col-sm-12 col-lg-4 text-right mt-5 mt-lg-0">
                    <img src="images/logo-footer.png" class="img-fluid" alt="">
                    <p class="mt-4 text-right about">Since 1908 our family owned trucking firm has made every mile count for America's and Canada's shipping needs.</p>
                </div>
                <div class="col-12 mt-5">
                	<hr class="border-white mb-5">
                    <p class="copyright"><small>&copy; <script type="text/javascript">document.write(new Date().getFullYear());</script> TMS Motorfreight Service | <a href="privacy-policy.html">Privacy Policy</a> | Designed by <a href="https://www.sytekcom.com" target="_blank">Sytek</a>.</small></p>
                </div>
            </div>
        </div>
    </footer>
    <!-- FOOTER END -->

    <script src="js/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="js/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
</html>