PHP表单不在mysql表中更新日期

时间:2017-03-29 23:34:29

标签: php mysql forms

我正在为学校开展项目,我希望能够从php表单更新日期字段。当我尝试更新它更新的日期时,但是在MySQL表格中显示了这个函数。任何帮助将不胜感激

<?php

     if(isset($_POST['update'])) {
        $dbhost = "***";
        $dbuser = "****";
        $dbpass = "****";
        $dbname = "****";

        $conn = mysql_connect($dbhost, $dbuser, $dbpass);

        if(! $conn ) {
           die('Could not connect: ' . mysql_error());
        }


        $appt_confirm_num = $_POST['ApptConfirmation_Num'];
        $provider_confirm_date = ($_POST['ProviderConfirmDate']);
 $provider_confirm_date = date('Y-m-d', strtotime(str_replace('-', '/', $provider_confirm_date)));




        $sql = "UPDATE appointment ". "SET ProviderConfirmDate = $provider_confirm_date ". 
           "WHERE ApptConfirmation_Num = $appt_confirm_num" ;
        mysql_select_db('test_db');
        $retval = mysql_query( $sql, $conn );

        if(! $retval ) {
           die('Could not update data: ' . mysql_error());
        }
        echo "Updated data successfully\n";

        mysql_close($conn);
     }else {
        ?>


    <form method = "post" action = "<?php $_PHP_SELF ?>">
              <table width = "400" border =" 0" cellspacing = "1" 
                 cellpadding = "2">

                 <tr>
                    <td width = "100">Appointment Confirmation Number:</td>
                    <td><input name = "ApptConfirmation_Num" type = "text" 
                       id = "ApptConfirmation_Num"></td>
                 </tr>

             <tr>
                    <td width = "100">Provider Confirmation Date:</td>
                    <td><input name = "ProviderConfirmDate" type = "date" 
                       id = "ProviderConfirmDate"></td>
                 </tr>
                 <tr>
                    <td width = "100"> </td>
                    <td> </td>
                 </tr>

                 <tr>
                    <td width = "100"> </td>
                    <td>
                       <input name = "update" type = "submit" 
                          id = "update" value = "Update">
                    </td>
                 </tr>

              </table>
           </form>
        <?php
     }
  ?>

0 个答案:

没有答案