title: HTML Form passing a date field to MySQL database using PHP
body: <p>The issue I am having is that the data field (LDA) is not passing the information entered on the form into the $lda = date('Y-m-d H:i', strtotime($_POST['lda'])); When I look at the data submitted, regardless of what I submitted, I am getting a date of 1969-12-31 00:00:00. </p>
  
  <p>I used $lda = date('Y-m-d H:i', strtotime($_POST['lda'])); because I was getting a date type error and relized that it must be that the date needed formated for MySQL. </p>
  
  <p>I have the following very simple HTML form:            </p>
  
  <pre><code>&lt;form action="sd-drop-submit.php" method="post"&gt;
      &lt;p&gt;
          &lt;label&gt;Semester:&lt;/label&gt;    
          &lt;input type="radio" name="semester" value="Spring &lt;?php echo date("Y");?&gt;)"&gt;Spring &lt;?php echo date("Y");?&gt;
          &lt;input type="radio" name="semester" value="Summer &lt;?php echo date("Y");?&gt;"&gt;Summer &lt;?php echo date("Y");?&gt;
          &lt;input type="radio" name="semester" tooltip="Semester" value="Fall &lt;?php echo date("Y");?&gt;" required="yes" message="Please select the semester." tabindex="1"&gt;Fall &lt;?php echo date("Y");?&gt;  
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;label&gt;Student First Name:&lt;/label&gt; 
  
          &lt;input type="text" name="stdfname" tooltip="Student's First Name" required="yes" message="Please enter the student's first name." tabindex="2"&gt;&lt;br&gt;
          &lt;label&gt;Student Last Name:&lt;/label&gt; 
          &lt;input type="text" name="stdlname" tooltip="Student's Last Name" required="yes" message="Please enter the student's last name." tabindex="3"&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Student ID Number:&lt;/label&gt;
          &lt;input type="text" name="stdid" tooltip="Student ID Number" message="Please enter the student's ID number." required="yes" tabindex="4"&gt;
          &lt;label&gt;Program Code:&lt;/label&gt;
          &lt;input type="text" name="program" tooltip="Program Code" message="Please enter the student's program code." required="yes" tabindex="5"&gt;
      &lt;/p&gt; 
  
      &lt;p&gt;
          &lt;label&gt;Course:&lt;/label&gt; &lt;input type="text" name="course" tooltip="Course" required="yes" message="Please enter the course information." tabindex="6"&gt; (Example: ACA 111, ENG 101)
  
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Section:&lt;/label&gt; &lt;input type="text" name="section" tooltip="Section" required="yes" message="Please enter the section information." tabindex="7"&gt; (Example: 01, NT1)
  
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Last day of Attendance:&lt;/label&gt;
          &lt;input type="date" name="LDA" tooltip="Last Day of Attendance" required="yes" message="Please enter the last day of attendance." validate="date" tabindex="8"&gt; (Date Format Only - Please use the &lt;a href="SD_NA.cfm"&gt;Never Attended&lt;/a&gt; form if this student has never attanded.)&lt;br&gt;
      &lt;/p&gt;
  
      &lt;p&gt;
          &lt;label&gt;Reason:&lt;/label&gt;
          &lt;input type="radio" name="reason" tooltip="Reason" value="Employment" required="yes" message="Please select the reason this student is being dropped." tabindex="9"&gt;Employment
          &lt;input type="radio" name="reason" value="Excessive Absences"&gt;Excessive Absences
          &lt;input type="radio" name="reason" value="Illness (Personal/Family)"&gt;Illness (Personal/Family)
          &lt;input type="radio" name="reason" value="Missed Assignments"&gt;Missed Assignments
          &lt;input type="radio" name="reason" value="Student Request"&gt;Student Request
          &lt;input type="radio" name="reason" value="Other"&gt;Other
  
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Instructor First Name:&lt;/label&gt;
          &lt;input type="text" name="instfname" tooltip="Instructor's First Name" required="yes" message="Please enter the instructor's first name." tabindex="10"&gt;
      &lt;/p&gt; 
      &lt;p&gt;  
          &lt;label&gt;Instructor Last Name:&lt;/label&gt;
          &lt;input type="text" name="instlname" tooltip="Instructor's Last Name" required="yes" message="Please enter the instructor's last name." tabindex="11"&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Instructor Email:&lt;/label&gt;
          &lt;input type="text" name="instemail" tooltip="Instructor's Email" required="yes" message="Please enter the instructor's email." tabindex="12"&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label&gt;Comments:&lt;/label&gt;&lt;br&gt;
          &lt;textarea name="comments" tooltip="Comments" cols="100" rows="5" tabindex="13"&gt;&lt;/textarea&gt;&lt;/p&gt;
  
  
          &lt;input type="submit" name="Submit" value="Complete the request"&gt;
          &lt;input type="reset" name="Reset" value="Reset" id="Reset"&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and I am using the following PHP to INSERT INTO my database. </p>
  
  <pre><code> &lt;?php       
  //create connection
  $con = mysql_connect("localhost", "wccappcust", "Y3!!f00tb@11") or die ('Sorry, could not connect to the directory database server' .mysql_error());
  //Select database
  mysql_select_db("wccapp16", $con) or die ('Sorry, could not connect to the directory database' .mysql_error()); 
  
  $lda = date('Y-m-d H:i', strtotime($_POST['lda']));
  
  //Insert our data
  $sql="INSERT INTO sddrop (stdfname, stdlname, semester, stdid, program, course, section, lda, reason, instfname, instlname, instemail, comments)
  VALUES
  ('$_POST[stdfname]', '$_POST[stdlname]', '$_POST[semester]', '$_POST[stdid]', '$_POST[program]', '$_POST[course]', '$_POST[section]', '$lda', '$_POST[reason]', '$_POST[instfname]', '$_POST[instlname]', '$_POST[instemail]', '$_POST[comments]')";
  
  if (!mysql_query ($sql, $con))
  {
      die ('Error: ' .mysql_error());
  }
  echo "&lt;h2&gt;Please print for your records&lt;/h2&gt; ";
  echo "&lt;h3&gt;Student Drop Form&lt;/h3&gt;";
  
  echo "Student Name: $_POST[stdfname] $_POST[stdlname]&lt;br&gt;\n";
  echo "Student ID: $_POST[stdid]&lt;br&gt;\n";
  echo "Program: $_POST[program]&lt;br&gt;\n";
  echo "Semester: $_POST[semester]&lt;br&gt;\n";
  echo "Course: $_POST[course] $_POST[section]&lt;br&gt;\n";
  echo "Last Day Attended: $lda&lt;br&gt;\n";
  echo "Reason:$_POST[reason]&lt;br&gt;\n";
  echo "Comments: $_POST[comments]&lt;br&gt;\n";
  echo "&lt;hr&gt;";
  echo "Instructors Name: $_POST[instfname] $_POST[instlname]&lt;br&gt;\n";
  echo "Instructors Email: $_POST[instemail]&lt;br&gt;\n";
  
  mysql_close($con)     
   ?&gt;
  </code></pre>
  
  <p>What am I missing? </p>
  
  <p>Should I change </p>
  
  <pre><code>$lda = date('Y-m-d H:i', strtotime($_POST['lda'])); 
  </code></pre>
  
  <p>to be </p>
  
  <pre><code>$lda = $_POST (date('Y-m-d H:i', strtotime($_POST['lda'])));
  </code></pre>
  
  <p>I think I am so close. Any advice you can get is greatly appreciated. </p>