I get Undefined index: image error in this code. Can I know the exact solution? I wanna know workflow from line abc to xyz that I commented in the code using //.Thanks for your help..
<?php session_start();
include("config.php");
if(isset($_SESSION['name']))
{
if(!$_SESSION['name']=='admin')
{
header("Location:login.php?id=You are not authorised to access this page unless you are administrator of this website");
}
}
?>
<?php
$name=$_FILES['image']['name'];
$tmp=$_FILES['image']['tmp_name'];
$err=$_FILES['image']['error'];
}
if($err==0)
{
move_uploaded_file($tmp, $name);
//xyz}
$category=$_POST['category'];
$title=$_POST['title'];
$image=$_FILES["image"]["name"];
$content=$_POST['content'];
}
<?php
$qry=mysql_query("INSERT INTO articles(title,image,content,category)VALUES('$title','$image','$content','$category')");
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
else
{
echo "Article Added Successfully";
}
?>
The form code is here:
<?php
include("config.php");
$sql=mysql_query("select * from category");
if(!$sql)
{
mysql_error();
}
?>
<form action="created_article.php" method="post">
Category:
<select name="category">
<?php
while($row=mysql_fetch_array($sql))
{
echo"<option value='".$row['category']."'>".$row['category']."</option>";
}
?>
</select>
Title:
<input type="text" name="title"/>
Upload Image:
<input type="file" name="image" id="image" />
Contents:
<textarea name="content" cols="100" rows="12" ></textarea>
<input type="submit" name="button" value="Submit" />
</form>
I need help with these code, I need to make project and I'm stuck here, so please kindly I request for your help,