美国向用户提示的详细信息(通过php编码)isn';t显示在MySQL数据库中(localhost)

美国向用户提示的详细信息(通过php编码)isn';t显示在MySQL数据库中(localhost),php,mysql,Php,Mysql,我最近编写了一个php代码,提示用户输入他们的姓名、电子邮件、网站、评论和性别(我正在使用php编码)。当用户已经输入数据时,数据应该显示在我的本地主机MySQL数据库(phpmyadmin)中。但这里的问题是,无论我将INSERT放入函数的什么位置,用户输入的数据都不会被插入phpmyadmin中的表中。。是的,我已经成功地创建了表(使用php代码),但是细节似乎没有插入到我创建的表中 这是我的密码: <?php include "header.php"; include

我最近编写了一个php代码,提示用户输入他们的姓名、电子邮件、网站、评论和性别(我正在使用php编码)。当用户已经输入数据时,数据应该显示在我的本地主机MySQL数据库(phpmyadmin)中。但这里的问题是,无论我将INSERT放入函数的什么位置,用户输入的数据都不会被插入phpmyadmin中的表中。。是的,我已经成功地创建了表(使用php代码),但是细节似乎没有插入到我创建的表中

这是我的密码:

<?php
    include "header.php";
    include "lib/db.php";
    include "module/functions.php";

    error_reporting(0);
?>

<!DOCTYPE html>
<html>
<body>
    <form action="index.php" method="POST">

    <?php
        $name = "";
        $email = "";
        $gender = "";
        $comment = "";
        $website = "";
    ?>

    <center>
    <table border="13" width="400" height="400">
        <tr>
            <td colspan="5" align="center" bgcolor="blue">guest's information</td>
        </tr>

        <tr>
            <td align="right">Name:</td><td> <input type="text" name="name" value="<?php echo $name;?>"></td>
        </tr>

        <tr>
            <td align="right">E-mail: </td><td><input type="text" name="email" value="<?php echo $email;?>"></td>
        </tr>

        <tr>
            <td align="right">Website: </td>
            <td><input type="text" name="website" value="<?php echo $website;?>"></td>
        </tr>

        <tr>
            <td align="right">Comment: </td>
            <td><textarea name="comment" rows="10" cols="65"><?php echo $comment;?></textarea></td>
        </tr>

        <tr>
            <td align="right">Gender: </td>
        <td>
            <input type="radio" name="gender"<?php if ($gender=="female"); ?> value="female">Female
            <input type="radio" name="gender"<?php if ($gender=="male"); ?> value="male">Male
        <td>
        </tr>

        <tr>
            <td colspan="5" align="center"><input type="submit" name="submit" value="submit"></td>
        </tr>

        <tr>
            <td colspan="5" align="center"><input type="reset" name="reset" value="reset"></td>
        </tr>


<?php
    include "config.inc.php";
?>

<?php
    {
        $name = $_POST['name'];
        $email = $_POST['email'];
        $website = $_POST['website'];
        $comment = $_POST['comment'];
        $gender = $_POST['gender'];

        $query = "INSERT INTO myguests (name, email, website, comment, gender)
            VALUES ('$name', '$email', '$website' , '$comment' , '$gender')";   

    }

    if(isset($_POST['submit'])) {
        if($name !="" && $email !="" && $website !="" && $comment !="" && $gender !="") {
            $query = "INSERT INTO myguests (name, email, website, comment, gender)
                        VALUES ('$name', '$email', '$website' , '$comment' , '$gender')";

        echo "You've entered the data.";


        echo '<script language="javascript">';
        echo 'alert("Yo brother, sudah la brother.")';
        echo '</script>';

        } else {

            echo '<script language="javascript">';
            echo 'alert("Yo brother, fuck off. Isi elok-elok la brother.")';
            echo '</script>';       
        }
    } 


    ?>  
     </form>
   </body>
</html>

客人信息

名称:您的问题实际上在这里:

 if(isset($_POST['submit'])) {
        if($name !="" && $email !="" && $website !="" && $comment !="" && $gender !="") {
            $query = "INSERT INTO myguests (name, email, website, comment, gender)
                        VALUES ('$name', '$email', '$website' , '$comment' , '$gender')";

        echo "You've entered the data.";


        echo '<script language="javascript">';
        echo 'alert("Yo brother, sudah la brother.")';
        echo '</script>';

        }
修订守则:

        $query = "INSERT INTO myguests (name, email, website, comment, gender)
                        VALUES ('$name', '$email', '$website' , '$comment' , '$gender')";

        $result = mysql_query($query);

        echo "You've entered the data.";

我已经插入了
$result=mysql\u查询($query)插入到部件中,但用户提示的详细信息仍然没有插入到localhost phpmyadmin数据库中。。是否可能是因为phpmyadmin中存在一些设置错误,不允许我将数据插入数据库?
$result = mysql_query($query);
        $query = "INSERT INTO myguests (name, email, website, comment, gender)
                        VALUES ('$name', '$email', '$website' , '$comment' , '$gender')";

        $result = mysql_query($query);

        echo "You've entered the data.";