-1

I got a forum which you can post a title and description to it. So I got this database at the moment:

enter image description here

Now I want to be able to add an image to my post. I got a file upload page which I got from: http://bytes.com/topic/php/insights/740327-uploading-files-into-mysql-database-using-php Which I could use. But it wont make me see the image. Just the information of the image and the option to download it. It looks like this: enter image description here

After I post my post, I want to be able to just see the image when I look at my post. I think there must be a different way to do this, right?

EDIT: My post php code:

<?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>';
}
}
?>

I know about the sql injection...

Loko
  • 6,539
  • 14
  • 50
  • 78

1 Answers1

0

Loko you shouldn't put images in your database because of performance. You store the path to the image in your database.

take a look at this for uploading your images.

http://www.phphulp.nl/php/script/php-algemeen/image-upload-script/1484/imageuploadscript/1086/

Good Luck.

Robin
  • 392
  • 1
  • 2
  • 12