Yeah, I have posted on here about how to check for a title in the form before uploading, and at first it worked. Then it just stopped working. The script was never changed, here is the code for php script
Code:
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<?php
//check for title
if ($title = ' ')
{
echo 'Please enter a title and try again';
exit();
}
//Check first if a file has been selected
if (is_uploaded_file($_FILES['uploaded']['tmp_name']))
{
//Get the Size of the File
$size = $_FILES['uploaded']['size'];
//Get File Type
$file_type = $_FILES['uploaded']['type'];
//Make sure that $size is less than 3MB and file type is right
if ($size > 3000000)
{
//Print the error
echo 'File Too Large. Please select another File.';
exit();
}
else if ( $file_type != "audio/mpeg" && $file_type != "audio/wav" )
{
//print error
echo 'File Extension Incorrect. Please Select another file.';
exit();
}
//Move the File to the Directory of your choice
if (move_uploaded_file($_FILES['uploaded']['tmp_name'],'uploads/'.$_FILES['uploaded']['name'])) {
//tell the user that the file has been uploaded
echo 'File Uploaded!<br>';
echo 'It will be added to the licks page soon';
//email me the title etc
$myemail = "gezer77@theguitarlicks.com";
if (!isset($visitormail));
$todayis = date("l, F j, Y, g:i a") ;
$subject = "New File Uploaded" ;
$ip = getenv("REMOTE_ADDR");
$message = " Title: $title \n
IP = $ip \n ";
$from = "From: $myemail\r\n";
if ($myemail != "")
mail($myemail, $subject, $message, $from);
exit();
}
else
{
//Print error
echo 'Unable to move the File';
exit();
}
}
else
{
//Print error
echo 'No File Selected';
exit();
}
?>
A reason globals arent good is because of something like this:
Say this forum ran only with globals on, you could goto posting.php or something and use the textbox id in the url, and bang, you could post by refreshing, and refreshing, and refreshing...
It could also be used to run third party scripts on your site, to get passwords, to delete everything etc.