簡體   English   中英

向數據庫添加新文章不起作用

[英]adding new article to DB not working

我在我的add.php頁面上遇到了一些麻煩。 我嘗試了許多單獨的代碼,但不確定為什么它們似乎都不起作用。

沒有代碼添加到我的數據庫中,並且由於我打開了錯誤報告,因此它不會帶來任何報告。 所以我不確定為什么。

我的add.php頁面的代碼是:

    <?php

session_start();

include_once('../include/connection.php');

if (isset($_SESSION['logged_in'])){
      if (isset($_POST['title'], $_POST['content'])) {
             $title = $_POST['title'];
             $content = nl2br($_POST['content']);
             $image = $_POST['Image URL'];
             $link = $_POST['Link'];
             $price = $_POST['Price'];

if (empty($title) or empty($content)) {
             $error = 'All Fields Are Required!';
}else{
$query = $sql->prepare('INSERT INTO `xclocouk_mobile`.`mobi` (`promo_title`, `promo_content`, `promo_image`, `promo_link`, `promo_cat`) VALUES (?,?,?,?,?)');
     $query->bindValue(1, $Title);
     $query->bindValue(2, $Content);
     $query->bindValue(3, $Image);
     $query->bindValue(4, $Link);
     $query->bindValue(5, $Category);

     $query->execute();
    header('location: index.php');

}

}
          ?>

<html>
<head>
<title>testing</title>
<link rel="stylesheet" href="../other.css" />
</head>

<body>
<div class="container">
<a href="index.php" id="logo">CMS</a>

<br /><div align="center">


<h1>Add Article</h1>

<?php if (isset($error)) { ?>
     <small style="color:#aa0000;"><?php echo $error; ?></small><br /><br />
<?php } ?>


<form name = "myform" action="add.php" method="post" autocomplete="off">


<input type="text" name="Title" placeholder="Title" /><br /><br />
<textarea rows="15" cols="50" name="Content" placeholder="Content"></textarea><br /><br />
<input type="text" name="Image" placeholder="Image URL" /><br /><br />
<input type="text" name="Link" placeholder="Link" /><br /><br />
<input type="text" name="Category" placeholder="Category" /><br /><br />
 <input type="submit" name="submit" value="Add Article" />

</form></div>

</div>
</body>
</html>


<?php
}else{
       header('location: index.php');
}


?>

有誰知道為什么嗎?

謝謝。

您的變量都是小寫字母,但綁定值時,首字母大寫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM