Hi again
After a little more assistance. You have all been so great so far thought you may know what I have done wrong here.
The following code does 99% of what it supposed to do. The only problem is that when the user clicks the upload button and uploads the photographs (no problem with this bit), it also sends off an email. But for some reason ir is sending 2 emails each time. as follows
1st email:
has uploaded a new image. Please approve now!
Approve Now
2nd email
David (or whoever has done the upload) has uploaded a new image. Please approve now!
Approve Now
<html>
<head>
<title>Upload File To MySQL Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="corestyles.css" rel="stylesheet" type="text/css">
</head>
<body>
<?
// you can change this to any directory you want
// as long as php can write to it
$uploadDir = 'pictures/';
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$comment = $_POST['comment'];
$title = $_POST['title'];
$member = $_POST['member'];
// the files will be saved in filePath
$filePath = $uploadDir . $fileName;
// move the files to the specified directory
// if the upload directory is not writable or
// something else went wrong $result will be false
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include 'library/config.php';
include 'library/opendb.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO upload2 (name, size, type, path, comment, title, member ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$comment', '$title', '$member')";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
include 'library/closedb.php';
echo "<br>File uploaded<br>";
}
$movedtolocation="pictures/".$_FILES['upload']['name'];# basically, take the location of wher the image is stored..
$msg = $_POST['member']." has uploaded a new image. Please approve now! <br /><br /><a href='http://www.grap.co.uk/admin2.php'>Approve Now</a>";
mail("graham@ripla.co.uk","New Image Uploaded",$msg,"content-type:text/html\n\n");
?>
<h2 align="center">Upload Your Picture </h2>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="456" border="0" align="center" cellpadding="1" cellspacing="1" class="box">
<tr>
<td width="182"><p>Your Name:</td>
<td width="265"><p> <input name="member" type="text" size="35"></td>
</tr>
<tr>
<td width="182"><p>Picture Title:</td>
<td width="265"><p> <input type="text" name="title" size="35"></td>
</tr>
<tr>
<td><p>Select Photograph to upload:</p></td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile" size="35">
</td>
<tr>
<td><p>Comment:</p>
<p class="small"><em>Note: Comments are limited to 250 characters</em>)</p></td>
<td><textarea rows="10" name="comment" cols="30"></textarea></td>
</tr>
<tr>
<td></td>
<td> </td>
</tr>
<tr><td width="182"></td>
<td width="265"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
<p> </p>
<p align="center"><img src="images/top_ranim.gif" width="303" height="63"></p>
</form>
</body>
</html>
Has anyone any ideas as to what I have done wrong. I am still relatively new to this and just cant see what I have done wrong.
Thanks in advance