That's worked perfect BUT in my case didn't, why?
Here is my form
<form action="post_processing.php?<? echo SID ?>" method="post" enctype="multipart/form-data">
<tr> <td colspan="3" align="center">Category : <select name="category" >
<option value="">ÅðéëÝîôå ìßá êáôçãïñßá</option>
<option value="">----------------------</option>
<? mysql_connect("localhost");mysql_select_db(db_name);
$result1=mysql_query("SELECT category FROM categories");
while($row=mysql_fetch_assoc($result1)) {
echo "<option value=".$row['category'].">".$row['category']."</option>";}
?></select></td></tr>
<tr> <td colspan="3" align="center">
Title <br>
<input type"text" name="title" size="100"> </td></tr> <tr> <td colspan="3" align="center" valign="middle">
<table align="center" valign="baseline" width=100% height=100%> <tr> <td colspan="3" align="center" valign="middle">
Text Here<br><textarea name="text" rows="20" cols="90" wrap="hard"></textarea></td></tr></table>
</td></tr>
<tr><td colspan="3" align="center">Öùôïãñáößá <input type="file" name="file"> </td></tr>
<tr> <td height="2" align="center"><input type=submit name=preview value=Ðñïåðéóêüðéóç></td><td height="2" align="center"><input type=submit name=send value=ÁðïóôïëÞ></td><td height="2" align="center"><input type=reset value=Clear></td></tr>
</form>
and the proseccing.php is that
<? session_start();
if($_SESSION['id']) {include("db_name.php");
mysql_connect("localhost");mysql_select_db(db_name);
$user_id=$_SESSION['id'];
$result=mysql_query("SELECT username FROM users WHERE userid=$user_id");
$user_element=mysql_fetch_assoc($result);
if($_POST["send"]) {
if(($_POST['category'])&&($_POST['title'])&&($_POST['text'])) {
$result_categoryid=mysql_query("SELECT categoryid FROM categories WHERE category='".$_POST['category']."'");
$categoryid=mysql_fetch_assoc($result_categoryid);
if($_FILES['file']['name']) {
$type_image=@getimagesize($_FILES['file']['tmp_name']);
if($type_image[2]){
$name=$_FILES['file']['name'];
if (is_uploaded_file($_FILES['file']['tmp_name']))
{
copy($_FILES['file']['tmp_name'], "images/".$name);
$result=mysql_query("SELECT id FROM post ORDER BY id DESC LIMIT 1");
$prefix=mysql_fetch_assoc($result);
$i=$prefix['id'];
$new_prefix=++$i;
$extention=substr($name,strrpos($name,"."));
echo $newFileName=$new_prefix.$extention;
rename("images/$name","images/$newFileName");
unlink($_FILES['file']['tmp_name']);}
mysql_query("INSERT INTO post VALUES (NULL,'".$user_element['userid']."','".$_POST['title']."','".$categoryid['categoryid']."','".$_POST['text']."','$newFileName',now(),DATE_ADD(now(),INTERVAL 2 MONTH)");
echo "<div align='center' valign='center'> Successfully Recorded To Database And The Post Will Be Shown In A While </div>";
echo "<meta http-equiv='refresh' content='2; url=text_post.php?".SID."'>"; }
else echo "You must enter an image file"; }
else mysql_query("INSERT INTO post VALUES (NULL,'".$user_element['userid']."','".$_POST['title']."','".$categoryid['categoryid']."','".$_POST['text']."','',now(),DATE_ADD(now(),INTERVAL 2 MONTH)");
} else "You must fill al the fields"; }
mysql_close();
?>
</body>
</html><? }
else echo "Authentication Required";?>