I'm experimenting out premade codes and trying to make them some how work the way I want to. This is "my" image uploader. For the uploader is suppose to find the image AND the code stored in mysql, but it doesn't seem to find it. any problem?
<?php
$link = mysql_connect("localhost", "mcd", "whatanicepassword");
mysql_select_db("mcd", $link);
if (!isset($_POST["code"]))
{
die ("Error: Not all fields complete");
}
$limit_size=5120;
$target = "skin/";
$target = $target . basename( $_FILES['uploaded']['name']);
$ok=1;
$filelol = $_FILES['uploaded']['name'];
$file_size=$_FILES['uploaded']['size'];
$filecheck = "skin/".$filelol;
//This is our size condition
if ($file_size >= $limit_size)
{
echo "Your file is too large.<br>";
$ok=0;
}
if (file_exists($filecheck))
{
} else {echo $filelol." does not exist in the database. Please upload at the main site.<br>";
$ok=0;}
// username and password sent from Form
$uploaded=mysql_real_escape_string($_POST['uploaded']);
$code=mysql_real_escape_string($_POST['code']);
$checkquery = mysql_query("SELECT * FROM user_list WHERE uploaded = '$uploaded' AND code = '$code'") or die("Error : " . mysql_error());
$num_rows=mysql_num_rows($checkquery);
if ($num_rows < 1 ) {
echo 'File not found in MySQL<br><br><br>';
$ok=0;
}
else
{echo 'YES!';}
//This is our limit file type condition
if (($_FILES["uploaded"]["type"] != "image/png"))
{
echo "You may only upload PNG files.<br>";
$ok=0;
}
if ($ok==0)
{
Echo "Sorry your file was not uploaded<br>";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".$filelol." has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>