Ok. I have searching on this site Since August 24 2011.(not that it matters) for a way to display files that have been uploaded by a user. I have my form on the admin side a
Something very basic that you might have missed is the form enctype. Many begginers does this. So just check if you have the enctype attribute in the form.
<form enctype="multipart/form-data">
Only if you have this you can upload files through your forms. Another place where you could possibly gone wrong is
$query = "INSERT INTO user_DB VALUES ('','$company', '$location', '$userfile' )";
You store the file name in a variable called $pic but here you have given $userfile so just try changing that into $pic.
Some suggestions for what you could change to get this working.
What does your form tag look like? Don't forget to include the enctype
parameter as per below:
<form type="post" action="" enctype="multipart/form-data">
...
</form>
$company = mysql_real_escape_string($_POST['company']);
$location = mysql_real_escape_string($_POST['location']);
$pic = mysql_real_escape_string($_FILES['userfile']['name']);
The above lines are the first step in helping to prevent your queries from suffering SQL injection attacks.
$userfile
does not exist as you have actually assigned the file name to $pic
instead so your query should look like this:
$query = "INSERT INTO user_DB
VALUES ('','$company', '$location', '$pic')";
Now to link to the file in your output table:
echo "<td>";
echo "<a href=" . $target_path . basename($row['userfile']) . ">
{$row['userfile']}</a>";
echo "</td>";
i think sould replace this
$query = "INSERT INTO user_DB VALUES ('','$company', '$location', '$userfile' )";
with
$query = "INSERT INTO user_DB VALUES ('','$company', '$location', '$pic' )";
you can use one column as auto_increament
when you are inserting a new user than you can get sum of already registered users using this query
$qry = mysql_qyery("select * from users
");
and you can get user count by using
$count = mysql_num_rows($qry); so after this you insert a new user and his ID will be
$count1 = $count+1; $id = 'F'.$count1;