$ _GET工作正常,但插入查询不工作

时间:2019-06-27 09:41:28

标签: php mysql

执行后,我在我的网址中得到了addnewtopic.php?cid = 1&scid = 3 但是没有将数据插入数据库,并且页面仍然空白,没有任何错误

$topic = addslashes($_POST['topic']);
$content = nl2br(addslashes($_POST['content']));
$cid = mysqli_real_escape_string($con,$_GET['cid']);
$scid = mysqli_real_escape_string($con,$_GET['scid']);


$insert = mysqli_query($con, "INSERT INTO topics 
                (`category_id`, `subcategory_id`, `author`, 
                `title`, `content`, `date_posted`) 
        VALUES ('".$cid."', '".$scid."', '".$_SESSION['username']."', 
                '".$_POST['topic']."', '".$_POST['content']."', NOW());");

这是表格

<?php 
    if (isset($_SESSION['username'])) {
          echo "<form action='/forum/addnewtopic.php? 
               cid=".$_GET['cid']."&scid=".$_GET['scid']."'method='POST'>
                <p>Title: </p>
                <input type='text' id='topic' name='topic' size='100' />
                <p>Content: </p>
                <textarea id='content' name='content'></textarea><br />
                <input type='submit' value='add new post' /></form>";
    } else {
        echo "<p>please login first or <a href='/forum/register.html'>click here</a> to register.</p>";
    } 
?>

0 个答案:

没有答案