Hello everyone,
Can't seem to find the error in this, but here we go...
PROBLEM: File not uploading and because of that not storing the right thing into the database either
FORM SCRIPT:
<?php
include "header.php";
?>
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td>
<form method="POST" action="postmachine.php">
<p align="center"><b>
<font face="Arial" size="4">New Machine</font></b></p>
<p align="center"><b>
<font face="Verdana" size="2">Brand</font></b><font face="Verdana"><b><font size="2">: </font></b>
<input name="brand" size="48" style="font-weight: 700"><b><br>
<font size="2">Model: </font>
</b>
<input name="model" size="48" style="font-weight: 700"><br><br>Image:<br><input name="uploaded" type="file" /></font></p>
<p align="center">
<input type="submit" value="Post" name="B1"></p>
</form>
</td>
</tr>
</table>
<?php
include "footer.php";
?>
UPLOAD SCRIPT:
<?php
include "header.php";
$target = "products/";
$target = $target . basename( $_FILES['uploaded']['name']);
echo $target;
$ok=1;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
$endfile = substr($target,strlen('products/'));
}
else {
$endfile = "nopic.gif";
}
$brand = $_POST['model'];
$model = $_POST['brand'];
//WHOSE CHILD IS THIS?!?!?
$result = mysql_query("INSERT INTO `machines` (`id`, `brand`, `model`, `photo`) VALUES ('', '$brand', '$model', '$endfile');");
if (!$result) {
echo mysql_error();
exit;
}
?>
<table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td>
<p align="center"><font face="Verdana" size="2">Machine Posted!
</font>
</td>
</tr>
</table>
<?php
include "footer.php";
?>
I just can't figure out why it won't upload the file... any help?
Thanks,
~ Reality