Posted: Wed Mar 03, 2004 1:02 am
It doesn't. Just do this...
Code: Select all
<?php
error_reporting(E_ALL);
//MySQL Variables
$host = "host";
$login_name = "login";
$password = "pass";
//Connecting to MYSQL
MySQL_connect("$host","$login_name","$password") or die(mysql_error());
//Select the database
MySQL_select_db("bandsandmembers") or die("Could not select database");
//Assign contents of form to variables
$bandname = $_POST['band_name'];
$description = $_POST['description'];
$history = $_POST['history'];
$influences = $_POST['influences'];
$genra = $_POST['genra'];
$email = $_POST['email'];
$website = $_POST['website'];
$imagefile = $_FILES['imagefile']['name'];
$mp3file = $_FILES['mp3file']['name'];
$types = array("image/gif","image/jpeg","image/bmp","image/pjpeg","image/x-windows-bmp");
$types2 = array("audio/mpeg","audio/mp3","audio/x-mpeg-3","audio/x-mp3","audio/m3u","audio/x-m3u","application/x-compressed","application/zip","multipart/x-zip","application/x-troff-msvideo","video/msvideo","video/x-msvideo","application/x-compressed","video/avi","video/mpeg","audio/mpeg3","video/mpeg","video/x-mpeg");
//This is the File upload part
$uploaddir = $_SERVER['DOCUMENT_ROOT'].'/localmm/upload/';
$uploadfile1 = $uploaddir . $_FILES['imagefile']['name'];
$uploadfile2 = $uploaddir . $_FILES['mp3file']['name'];
if(empty($_FILES['imagefile']['name'])){
echo 'No image was uploaded.<br />';
}
if(empty($_FILES['mp3file']['name'])){
echo 'No mp3 was uploaded.<br />';
}
//Check to see weather there is a file in our upload folder with the same name
if(!empty($_FILES['imagefile']['name']) && file_exists($uploaddir . $imagefile)) {
echo "There is already a file called <b>$imagefile</b> on our server. <b>Please rename this file.</b> <br><br>Click the Back button and RE-SUBMIT.";
exit;
}
//Check to see weather there is a file in our upload folder with the same name
if(!empty($_FILES['mp3file']['name'])file_exists($uploaddir . $mp3file)) {
echo "There is already a file called <b>$mp3file</b> on our server. <b>Please rename this file.</b> <br><br>Click the Back button and RE-SUBMIT.";
exit;
}
if (in_array($_FILES['imagefile']['type'], $types)){
move_uploaded_file($_FILES['imagefile']['tmp_name'], $uploadfile1);
}else{
echo "There was an error when uploading. Your file could have been too big. or Check to see if you uploaded the correct file type. Allowd file types are. .gif, .jpg, .jpeg, .bmp";
}
if (in_array($_FILES['mp3file']['type'], $types2)){
move_uploaded_file($_FILES['mp3file']['tmp_name'], $uploadfile2);
}else{
echo "There was an error when uploading. Your file could have been too big. or Check to see if you uploaded the correct file type. Allowd file types are. .mp3, .avi, .mpg, .mpeg, .zip";
}
$sql = "INSERT INTO $genra (band_name, description, history, influences, genra, email, website, imagefile, mp3file) VALUES ('$bandname','$description','$history','$influences','$genra','$email','$website','$imagefile','$mp3file')";
mysql_query($sql) or die(mysql_error());
//Close connection with MySQL
mysql_close()
?>