Forum Moderators: coopster
<?php
//variables from form post (uploaded file 'file', category 'category', submitter 'submitter', the_url, 'the url related to the file', checkbox 'checkbox-has to be cheked in order to send the form data', thedate 'the date the form is prosessed'
$file_Name = $_FILES['file']['name'];
$file_Size = $_FILES['file']['size'];
$file_Temp = $_FILES['file']['tmp_name'];
$file_Mime_Type = $_FILES['file']['type'];
$category = addslashes($_POST['category']);
$submitter = addslashes($_POST['submitter']);
$the_url = addslashes($_POST['the_url']);
$checkbox = addslashes($_POST['checkbox']);
$thedate = addslashes($_POST['thedate']);
// Validation
if (strlen($file) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please select file</font></p>");
}
if (strlen($category) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please select category</font></p>");
}
if (strlen($checkbox) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please check!</font></p>");
}
//connecting to db
$username="username";
$password="password";
$database="database";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//insert data
$query = "INSERT INTO uploaded_files VALUES ('','$file','$category','$submitter','$the_url','$checkbox','$the_date')";
mysql_query($query);
echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Success uploading</font></p>");
mysql_close();
?>
There is also great documentation on file uploads at php.net. You might want to take a look there, too: [php.net...]
error_reporting(E_ALL);
Also, to debug your mysql query, use mysql_error().
mysql_query($query) or die(mysql_error());
You`ll see some error messages when you use these features, but this should help you sort out a few problems.
dc