Made a few tweaks. The image is now there but the path is still null.
Oh, and the form.
<form action="success_neworder.php" method="post" enctype="multipart/form-data">
<table id="contable">
<tr><th colspan="2">Add Order</th></tr>
<tr><td>Product and Quantity</td><td>
<input type="radio" value="Slimfit Shirt" name="prod"/>Slimfit Shirt<select style="float:right" name="qty-slimfit"><option value="0">Select quantity</option><option value="30">30</option><option value="50">50</option><option value="75">75</option><option value="100">100</option><option value="200+">200+</option></select><br/>
<input type="radio" value="T-Shirt" name="prod"/>T-shirt <select style="float:right" name="qty-tee"><option value="0">Select quantity</option><option value="30">30</option><option value="50">50</option><option value="75">75</option><option value="100">100</option><option value="200+">200+</option></select><br/>
<input type="radio" value="Polo Shirt" name="prod"/>Polo Shirt <select style="float:right" name="qty-polo"><option value="0">Select quantity</option><option value="30">30</option><option value="50">50</option><option value="75">75</option><option value="100">100</option><option value="200+">200+</option></select><br/>
<input type="radio" value="Baller" name="prod"/>Baller <select style="float:right" name="qty-baller"><option value="0">Select quantity</option><option value="500">500</option><option value="1000">1000</option></select><br/>
<input type="radio" value="Lanyard" name="prod"/>Lanyard <select style="float:right" name="qty-lanyard"><option value="0">Select quantity</option><option value="100">100</option></select><br/>
</td></tr>
<tr><td>Describe your order</td><td><input type="text" name="descr"/></td></tr>
<tr><td>Upload a Design <small><small>(Optional)</small></small></td><td><input type="file" name="image" value="image"/></td></tr>
<tr><td><input type="submit" name="add" value="submit"/></td></tr>
</table>
</form>
Some lines from success_neworder.php
if($total_amount!=0)
{
//add order to database
$query=mysql_query("INSERT INTO order_t(order_desc, prod, prod_qty, total_amount, order_date, cust_id) values('$descr', '$prod', '$qty', $total_amount, CURDATE(), $id)");
echo "<div id=\"panel\"><table id=\"contable\"><tr><th colspan=\"2\">New order has been added.</th></tr>";
echo "<tr><td><a href=\"cust_manageorders.php\">Back to Manage Orders</a></td></tr>";
echo "</table></div>";
if(isset($_FILES['image']))
{
//directory where images will be saved
$target = "uploaded_images/".$_SESSION['idnum']."/";
$pic=$_FILES['image']['name'];
//creates the directory
if(!is_dir($target))
{
mkdir($target,0777);
}
$image_path=$target.date("YmdHms").$pic;
if(move_uploaded_file($_FILES['image']['tmp_name'],$image_path))
{
$sql_query="INSERT INTO order_t(design) VALUES('$image_path') WHERE order_desc='$descr' AND cust_id=$id";
$result=mysql_query($sql_query,$con);
if($result)
{
echo "<div id=\"panel\"><p>Successfully image.</p></div>";
}
else echo "<div id=\"panel\"><p>Error uploading image.</p></div>";
}
else
{
echo "Error uploading. Please try again.";
}
mysql_close($con);
}
}
I get no error message, except "Error uploading image."
This isn't my code, really, and I don't understand what this statement
if(move_uploaded_file($_FILES['image']['tmp_name'],$image_path))
means at all 😕