success没有显示任何错误,但是任何数据都不会进入我的数据库

kqhtkvqz  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(172)
<?PHP
session_start();
if (isset($_SESSION['loggedin'])) {

    $loggedin = $_SESSION['loggedin'];
} else {

    header('Location: ../login');
}

$user = $_SESSION['ID'];
$kuva = "Space";
$date = gmdate("j\.m\.Y H:i:s ");

include 'config.php';

$query = $connection->query("INSERT INTO rate(userID, kuva, rate) VALUES(?,?,?)");
$query2 = $connection->query("INSERT INTO picture(nimi, userID, rate, kommentti) VALUES (?,?,?,?)");
$query3 = $connection->query("INSERT INTO comment(userID, picture, date, text) VALUES (?,?,?,?)");

$result = $connection->query("SELECT picture, date, text, user.username FROM comment INNER JOIN users WHERE picture = '$picture' LIMIT 3");

if (isset($_POST['submitPic'])) {
    if (isset($_POST['rating'])) {
        $rating = htmlspecialchars($_POST['rating']);
        $comment = htmlspecialchars($_POST['comment']);
        $query = array($user, $picture, $rating);
        $query2 = array($picture, $user, $rating, $comment);
        $success = '<span style="color:green;font-size:32px;">Success</span>';
    } else {
        $error = '<span style="color:red;font-size:32px;">Error</span>';
    }
}

if (isset($_POST['submitPic'])) {
    if (isset($_POST['comment'])) {

    } else {
        $query3 = array($user, $kuva, $date, $comment);
    }
}
$connection->close();
?>

我得到成功后,评级和评论,但任何数据都不会进入我的数据库
我的代码怎么了?成功没有任何错误显示在任何地方,但任何数据都不会进入我的数据库
我的数据库应该没有问题。只是我看不出错误
编辑:这是我的html
这是我的html

<!-- Star rating -->
    <center>
        <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
            <fieldset class="starability-basic"> 
                <input type="radio" id="rate1" name="rating" value="1" />
                <label for="rate1" title="1/10">1 star</label>

                <input type="radio" id="rate2" name="rating" value="2" />
                <label for="rate2" title="2/10">2 stars</label>

                <input type="radio" id="rate3" name="rating" value="3" />
                <label for="rate3" title="3/10">3 stars</label>

                <input type="radio" id="rate4" name="rating" value="4" />
                <label for="rate4" title="4/10">4 stars</label>

                <input type="radio" id="rate5" name="rating" value="5" />
                <label for="rate5" title="5/10">5 stars</label>

                <input type="radio" id="rate6" name="rating" value="6" />
                <label for="rate6" title="6/10">6 stars</label>

                <input type="radio" id="rate7" name="rating" value="7" />
                <label for="rate7" title="7/10">7 stars</label>

                <input type="radio" id="rate8" name="rating" value="8" />
                <label for="rate8" title="8/10">8 stars</label>

                <input type="radio" id="rate9" name="rating" value="9" />
                <label for="rate9" title="9/10">9 stars</label>

                <input type="radio" id="rate10" name="rating" value="10" />
                <label for="rate10" title="10/10">10 stars</label>
            </fieldset>
    </center>

    <center>
        <textarea name="comment" cols="50" rows="4"></textarea>
    </textarea>
</center>
<center>
    <button type="submit" name="submitPic" class="submitPic">Send</button>
</center>
</form>
68bkxrlz

68bkxrlz1#

你为什么不用事先准备好的陈述呢。

$query = $connection->prepare("INSERT INTO rate(userID, kuva, rate) VALUES(?,?,?)");
$query->bind_param('iii', $user, $picture, $rating);
$query->execute();
$query->close();

相关问题