title: Can't get form to submit information to PHP page
body: <p>I'm working on a web form that allows people to input user information into a reservations page, which will submit to a different page using PHP. As of now, when I click my submit button, it takes me straight to my PHP page but it just displays the PHP code, and not the information they submitted. I want to be able to click the submit button and display the information on my contactform.php page.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;title&gt;Reservations&lt;/title&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
     &lt;link rel="stylesheet" type="text/css" href="travel.css"&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"&gt;&lt;/script&gt;
     &lt;link rel="icon" href="travel.png"&gt;
  &lt;/head&gt;
   &lt;header&gt;
        &lt;img class="imageheader" src="travel.PNG" alt="megatravel" align="left" width="145" height="145"&gt;
  &lt;div class="wrapper"&gt;
      &lt;nav role="navigation"&gt;
        &lt;h1&gt;&lt;a href="travelindex.html"&gt;Mega Travel&lt;/a&gt;&lt;/h1&gt;
        &lt;ul class="nav-ul"&gt;
          &lt;li&gt;&lt;a href="travelindex.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="aboutus.html"&gt;About Us&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="reservations.html"&gt;Reservations&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;a href="aboutus.html"&gt;&lt;a/&gt;
      &lt;a href="travelindex.html"&gt;&lt;a/&gt;
      &lt;/nav&gt;
    &lt;/header&gt;
  
  &lt;img class="image1" src="brisbane.png" align="middle" height="330" width="870" border="inset"/&gt;
  &lt;img class="image2" src="vancouver.png" align="middle" height="340" width="870" border="inset"/&gt;
  &lt;img class="image3" src="newyorkcity.png" align="middle" height="340" width="870" border="inset"/&gt;
  &lt;img class="image4" src="berlin.png" align="middle" height="340" width="870" border="inset"/&gt;
  
  &lt;div class="col-sm-4" style="background-color:white";&gt;
  
        &lt;h1 class="form-group"&gt;Reservations&lt;/h1&gt;
        &lt;form action="contactform.php" method="post" id="travelform"&gt;
          &lt;fieldset&gt;
            &lt;legend&gt;Contact Information&lt;/legend&gt;
            &lt;label for="firstname"&gt;First Name:&lt;/label&gt;
            &lt;input type="text" id="firstName" name="firstname" class="form-control"&gt;&lt;br&gt;
            &lt;label for="middlename"&gt;Middle Name:&lt;/label&gt;
            &lt;input type="text" id="middleName" name="middlename" class="form-control"&gt;&lt;br&gt;
            &lt;label for="lastname"&gt;Last Name:&lt;/label&gt;
            &lt;input type="text" id="lastName" name="lastname" class="form-control"&gt;&lt;br&gt;
            &lt;label for="phone"&gt; Phone Number: &lt;/label&gt;
            &lt;input type="tel" id="phoneNum" name="phone" class="form-control"&gt;&lt;br&gt;
            &lt;label for="email"&gt;Email Address: &lt;/label&gt;
            &lt;input type="email" id="Email" name="email" class="form-control"&gt;&lt;br&gt;
          &lt;/fieldset&gt;
  &lt;fieldset&gt;
    &lt;legend&gt;Travel Information&lt;/legend&gt;
       &lt;label for="locations"&gt;Current Locations:&lt;/label&gt;
         &lt;select name="locations" id="Locations" onchange="changeActivities()" class="form-control"&gt;
          &lt;option value="australia"&gt;Brisbane&lt;/option&gt;
          &lt;option value="canada"&gt;Vancouver&lt;/option&gt;
          &lt;option value="newyork"&gt;New York City&lt;/option&gt;
          &lt;option value="germany"&gt;Berlin&lt;/option&gt;
          &lt;option value="mexico"&gt;Cancun&lt;/option&gt;
           &lt;/select&gt;&lt;br&gt;
            &lt;label for="depart_Date"&gt;Departure Date: &lt;/label&gt;
            &lt;input type="date" name="depart_Date" id="depart_Date" class="form-control"&gt;
            &lt;label for="return_Date"&gt;Return Date: &lt;/label&gt;&lt;br&gt;
            &lt;input type="date" name="return_Date" id="return_Date" class="form-control"&gt;
            &lt;label for="needed"&gt;Options&lt;/label&gt;&lt;br&gt;
            &lt;input type="checkbox" name="needed" value="flight"&gt; Flight&lt;br&gt;
            &lt;input type="checkbox" name="needed" value="hotel"&gt; Hotel&lt;br&gt;
            &lt;input type="checkbox" name="needed" value="car"&gt; Rental Car&lt;br&gt;
  &lt;/fieldset&gt;
    &lt;div id="activities" class=""&gt;
                      &lt;label class=""&gt;Choose an Activity&lt;/label&gt;
                      &lt;select id="activitiesList" name="activities" class="form-control"&gt;
                      &lt;/select&gt;
                  &lt;/div&gt;
  
  &lt;fieldset&gt;
   &lt;legend&gt;Billing Information&lt;/legend&gt;
     &lt;label for="line1"&gt;Address Line 1:&lt;/label&gt;
       &lt;input type="text" id="line1" name="line1" class="form-control"&gt;
         &lt;label for="line2"&gt;Address Line 2:&lt;/label&gt;
       &lt;input type="text" id="line2" name="line2" class="form-control"&gt;
         &lt;label for="city"&gt;City: &lt;/label&gt;
       &lt;input type="text" name="city" class="form-control"&gt;&lt;br&gt;
         &lt;label for="state"&gt;State: &lt;/label&gt;
       &lt;select name="state" id="state"&gt;
           &lt;option value="AL"&gt;Alabama&lt;/option&gt;
           &lt;option value="AK"&gt;Alaska&lt;/option&gt;
           &lt;option value="AZ"&gt;Arizona&lt;/option&gt;
           &lt;option value="AR"&gt;Arkansas&lt;/option&gt;
           &lt;option value="CA"&gt;California&lt;/option&gt;
           &lt;option value="CO"&gt;Colorado&lt;/option&gt;
           &lt;option value="CT"&gt;Connecticut&lt;/option&gt;
           &lt;option value="DE"&gt;Delaware&lt;/option&gt;
           &lt;option value="DC"&gt;District Of Columbia&lt;/option&gt;
           &lt;option value="FL"&gt;Florida&lt;/option&gt;
           &lt;option value="GA"&gt;Georgia&lt;/option&gt;
           &lt;option value="HI"&gt;Hawaii&lt;/option&gt;
           &lt;option value="ID"&gt;Idaho&lt;/option&gt;
           &lt;option value="IL"&gt;Illinois&lt;/option&gt;
           &lt;option value="IN"&gt;Indiana&lt;/option&gt;
           &lt;option value="IA"&gt;Iowa&lt;/option&gt;
           &lt;option value="KS"&gt;Kansas&lt;/option&gt;
           &lt;option value="KY"&gt;Kentucky&lt;/option&gt;
           &lt;option value="LA"&gt;Louisiana&lt;/option&gt;
           &lt;option value="ME"&gt;Maine&lt;/option&gt;
           &lt;option value="MD"&gt;Maryland&lt;/option&gt;
           &lt;option value="MA"&gt;Massachusetts&lt;/option&gt;
           &lt;option value="MI"&gt;Michigan&lt;/option&gt;
           &lt;option value="MN"&gt;Minnesota&lt;/option&gt;
           &lt;option value="MS"&gt;Mississippi&lt;/option&gt;
           &lt;option value="MO"&gt;Missouri&lt;/option&gt;
           &lt;option value="MT"&gt;Montana&lt;/option&gt;
           &lt;option value="NE"&gt;Nebraska&lt;/option&gt;
           &lt;option value="NV"&gt;Nevada&lt;/option&gt;
           &lt;option value="NH"&gt;New Hampshire&lt;/option&gt;
           &lt;option value="NJ"&gt;New Jersey&lt;/option&gt;
           &lt;option value="NM"&gt;New Mexico&lt;/option&gt;
           &lt;option value="NY"&gt;New York&lt;/option&gt;
           &lt;option value="NC"&gt;North Carolina&lt;/option&gt;
           &lt;option value="ND"&gt;North Dakota&lt;/option&gt;
           &lt;option value="OH"&gt;Ohio&lt;/option&gt;
           &lt;option value="OK"&gt;Oklahoma&lt;/option&gt;
           &lt;option value="OR"&gt;Oregon&lt;/option&gt;
           &lt;option value="PA"&gt;Pennsylvania&lt;/option&gt;
           &lt;option value="RI"&gt;Rhode Island&lt;/option&gt;
           &lt;option value="SC"&gt;South Carolina&lt;/option&gt;
           &lt;option value="SD"&gt;South Dakota&lt;/option&gt;
           &lt;option value="TN"&gt;Tennessee&lt;/option&gt;
           &lt;option value="TX"&gt;Texas&lt;/option&gt;
           &lt;option value="UT"&gt;Utah&lt;/option&gt;
           &lt;option value="VT"&gt;Vermont&lt;/option&gt;
           &lt;option value="VA"&gt;Virginia&lt;/option&gt;
           &lt;option value="WA"&gt;Washington&lt;/option&gt;
           &lt;option value="WV"&gt;West Virginia&lt;/option&gt;
           &lt;option value="WI"&gt;Wisconsin&lt;/option&gt;
           &lt;option value="WY"&gt;Wyoming&lt;/option&gt;
              &lt;/select&gt;&lt;br&gt;&lt;br&gt;
              &lt;label for="zip"&gt;Zip Code: &lt;/label&gt;
              &lt;input type="text" name="zip" id="zip" class="form-control"&gt;&lt;br&gt;
   &lt;/fieldset&gt;
       &lt;button type="submit" form="travelform" value="Submit"&gt;&lt;strong&gt;Submit&lt;/button&gt;
      &lt;/form&gt;
  
   &lt;/div&gt;
    &lt;div class="row text-center"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
   &lt;/div&gt;
    &lt;/body&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <pre><code> &lt;?php
  
   $required = array('firstname', 'lastname', 'phone', 'email', 'locations', 'depart_Date', 'return_Date');
  
  if (isset($_POST['submit']))
  
  {
  echo "Hello, a client has submitted their information for you to review!:&lt;br&gt;";
  
  echo "&lt;br&gt;First Name: ".$_POST['firstname']."
  &lt;br&gt;
  Middle Name: ".$_POST['middlename']."
  &lt;br&gt;
  Last Name: ".$_POST['lastname']."
  &lt;br&gt;
  Phone Number: ".$_POST['phone']."
  &lt;br&gt;
  Email: ".$_POST['email']."
  &lt;br&gt;
  Destination: ".$_POST['locations']."
  &lt;br&gt;
  Departure Date: ".$_POST['depart_Date']."
  &lt;br&gt;
  Return Date: ".$_POST['return_Date'];
  }
  
      function emailValidation($email) {
             if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                 return 1;
             } else {
                 return 0;
             }
          }
  
      function dateValidation($date, $format = 'Y-m-d')
          {
              $d = DateTime::createFromFormat($format, $date);
              return $d &amp;&amp; $d-&gt;format($format) === $date;
          }
  
      $servername = "localhost";
      $username = 'root';
      $password = '';
      $dbname = 'TravelDB';
  
      $conn = new mysqli($servername, $username, $password, $dbname);
  
      if ($conn-&gt;connect_error) {
          die("Failed to Connect: " . $conn-&gt;connect_error);
      }
  
      $sql = "INSERT INTO megaTravel (FirstName, MiddleName, LastName, PhoneNumber, Email, City, DepartureDate, ReturnDate)
      VALUES ('{$_POST['firstName']}', '{$_POST['middleName']}','{$_POST['lastName']}','{$_POST['phoneNum']}', '{$_POST['Email']}',
       {$_POST['Locations']}', '{$_POST['departure_Date]}', '{$_POST['return_Date']} )";
  
      if ($conn-&gt;query($sql) === TRUE) {
          echo "&lt;br&gt;&lt;br&gt;Success!&lt;br&gt;";
      } else {
          echo "&lt;br&gt;Error: " . $sql . "&lt;br&gt;" . $conn-&gt;error;
      }
  
      $sql = "SELECT * FROM megaTravel";
      $result = mysqli_query($conn, $sql);
      echo "&lt;br&gt;";
      echo "&lt;table border='1'&gt;";
      echo "&lt;tr&gt;";
      echo "&lt;td style='text-align: center; font-weight: bold'&gt;ID&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Name&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Phone&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Email&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Adults&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Children&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;City&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Travel_Date&lt;/td&gt;","&lt;td style='text-align: center; font-weight: bold'&gt;Activity&lt;/td&gt;";
      echo "&lt;/tr&gt;";
  
      while ($row = mysqli_fetch_assoc($result)) { 
          echo "&lt;tr&gt;";
          foreach ($row as $field =&gt; $value) { 
              echo "&lt;td&gt;" . $value . "&lt;/td&gt;"; 
          }
          echo "&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  
      $conn-&gt;close();
  
      ?&gt;
  </code></pre>