我有這2個PHP文件,我不知道爲什麼,但我得到了一個錯誤:指數沒有找到
SCREAM: Error suppression ignored for (!) Notice: Undefined index: content in D:\wamp\www\admin\add-script.php on line 11
這是附加的script.php
<?php
$con = mysqli_connect($host,$user,$password) or trigger_error("SQL", E_USER_ERROR);
$db = mysqli_select_db($con,$db) or trigger_error("SQL", E_USER_ERROR);
if (isset($_POST['send'])) {
$title = $_POST['title'];
$category = $_POST['category'];
$tags = $_POST['tags'];
$image = $_POST['image'];
$content = $_POST['content'];
$time = time();
$sql = "INSERT INTO articles (article_id, article_title, article_content, article_timestamp, article_tags, article_image, article_category) VALUES ('', '$title','$content','$time','$tags','$image','$category')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
('Location: index.php');
mysqli_close($con);
}
?>
這是add.php
<?php
session_start();
if (isset($_SESSION['logged_in'])) {
include_once ("header.php");
include_once ("add-script.php");
?>
<tr>
<td>
<form method="post" id="add" name="add" >
<div id="left-col">
<h1>Add Article</h1>
<input type="text" name="title" placeholder="Title" />
<textarea name="content" rows="30" id="markItUp content" cols="106" placeholder="Content"> </textarea>
<input type="text" name="tags" placeholder="Tags" />
<input type="text" name="image" placeholder="Image Name" />
</div>
<div id="right-col">
<?php
$result = mysql_query("SELECT * FROM category");
while($list = mysql_fetch_assoc($result)){
?>
<input type="radio" name = "category" value = "<?php echo $list['category_id']; ?>">
<label><?php echo $list['category_name']; ?></label>
<?php
}
?>
<input type="submit" name="send" value="Send!" style="margin-bottom:0px;"/>
</div>
</form>
</td>
<?php
include_once ("footer.php");
}
else {
header('Location: index.php');
}
?>
開始通過確保您的HTML是有效的:'DIV ID =「右山坳」>' – Madbreaks
對不起......現在到PHP的東西......爲什麼我得到這個錯誤? – user3128955
您的查詢全面開放SQL注入。你應該使用準備好的語句。 – Mike