插入不起作用的mysql.php


insert not functioning mysql php

我有一个问题。每次我插入它时,页面都会刷新并变为空白。我不知道问题出在哪里,但我检查了我的sql,我使用的数据是一样的。所以我不知道问题出在哪里。

                      <form enctype="multipart/form-data" method="POST">    <tr>
                        <td> Generic Name:<input type="text" class="form-control" name = "gname"></td>
                        </tr>
                        <tr>
                        <td> Brand Name:<input type="text" class="form-control" name = "bname"></td>
                        </tr>
                        <tr>
                        <td> Quantity:<input type="number" min="0" class="form-control" name = "mqty"></td>
                        </tr>
                        <tr>
                        <td> Description:<input type="text" class="form-control" name = "mdesc"></td>
                        </tr>
                        <br>
                        <tr>
                        <td> <input type="submit" class="btn btn-info" name="add" Value="Add"></td>
                        </tr>
               </form>
                <?php
                include "../../functions/connect.php";
                error_reporting(0);
                    date_default_timezone_set('Singapore');
                    $date = date('m/d/Y h:i:s a', time());

                    ?>
                    <?php
                    include "../../functions/connect.php"; 
                    extract($_POST);

                    if(isset($add)){
                        $sql = "INSERT INTO `tbl_meds`(`date`,`generic`,`brand`,`description`,`medqty`) VALUES ('$date','$gname','$bname','$mdesc','$mqty')";
                        $result = mysql_query($sql) or die("Verification Error: " . mysql_error());

                    }

            ?>

编辑:var_dump($_POST)-的结果

array(5) { 
    ["gname"]=> string(11) "Paracetamol" 
    ["bname"]=> string(8) "Biogesic" 
    ["mqty"]=> string(3) "100" 
    ["mdesc"]=> string(71) "The most prescribed Headache and Fever brand that's Effective and Safe." 
    ["add"]=> string(4) "Save" 
 }
if(isset($_POST["add"])){ 

这将为你工作

您的表单具有POST方法。因此,在PHP方面,您必须使用$_POST全局变量来处理它。