我有一个论坛,您可以在其中发布标题和描述。所以我现在得到了这个数据库:
现在我希望能够在我的帖子中添加图像。我得到了一个文件上传页面,我可以使用它: http ://bytes.com/topic/php/insights/740327-uploading-files-into-mysql-database-using-php 。但它不会让我看到图像。只是图像的信息和下载它的选项。它看起来像这样:
发布帖子后,我希望在查看帖子时能够看到图像。我认为必须有不同的方法来做到这一点,对吧?
编辑: 我的帖子 php 代码:
<?php
session_start();
$mysqli = new mysqli("localhost", "root", "usbw", "accounts");
$mysqli2 = new mysqli("localhost", "root", "usbw", "forum");
$alles_goed=false;
if(isset($_SESSION['username'])){
$usernamecheck = $mysqli->query("SELECT * from account_information where username ='". $_SESSION['username'] ."'");
if (isset($_POST['title'])) {
$alles_goed=true;
$description=$mysqli2->real_escape_string($_POST['description']);
$title=$mysqli2->real_escape_string($_POST['title']);
$usernameinsert=$mysqli2->real_escape_string($_SESSION['username']);
if($usernamecheck->num_rows==0){
$alles_goed=false;
}
if($alles_goed==true){
echo'<a href="questionprogramming.php">Back to programming</a>';
$a=date("Y-m-d H:i:s");
$resultaat = $mysqli2->query("INSERT INTO questions (title, description, username, date_made) VALUES ('" . $title . "','" . $description . "', '".$usernameinsert."','".$a."')");
}
}
if($alles_goed==false){
echo'<table>';
echo
<<<EOT
<form action="newquestion.php" method="post">
<tr><th><td><input type="text" size="108%" name="title"></td></tr></th>
<tr><th><td> <textarea name="description" rows="20" cols="80" ></textarea></td></tr></th>
<tr><th><td><input name="submit" type="submit" value="submit"></td></tr></th>
</form>
EOT;
echo'</table>';
}
}
?>
我知道sql注入...