Във формата ми за добавяне на новини искам да сложа и опция за добавяне на имидж, но явно някъде бъркам и не ми качва снимката в бд-то
Код:
<?php
include 'includes/connect.php';
if(isset($_POST['add']))
{
$time = time();
$title = htmlspecialchars($_POST['title']);
$content = strip_tags($_POST['content']);
$post_image= $_FILES['image'] ['name'];
$image_tmp= $_FILES['image'] ['tmp_name'];
$q = "INSERT INTO posts(post_title,post_content,post_author,added,post_image) VALUES('$title','$content','Papazov','$time','$post_image')";
mysql_query($q) or die (mysql_error());
}
?>
Код:
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Matchzone</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<p>
<form method="post" action="Addpost.php" enctype="multipart/form-data">
Заглавие: <input type="text" name="title" /><br/><br/>
<tr>
<td align="right">Ключови думи:</td>
<td><input type="text" name="keywords" size="30"></td>
</tr>
<br />
<br />
<tr>
<td align="right">Сложи снимка: </td>
<td><input type="file" name="image"></td>
</tr>
<br/><br/>
<textarea class="ckeditor" name= "content" cols="30" rows="10"></textarea><br />
<input type="submit" name="add" value="Добави" />
</form>
</p>
</body>
</html>