ok i have this form which sends all details to database and emails me with attachment if they have a photo
instead of that i wanted the photo to go to my server in a folder where all photos stored
this is my form
and here is the action formPHP Code:<form action="add1.php" method="post" enctype="multipart/form-data">
<table width="604" border="0" cellspacing="5">
<tr>
<td><span class="style2">Name: <span class="style3">not shown</span></span></td>
<td>
<div class="style2">
<input name="name" type="text" id="name" size="30" />
</div></td>
</tr>
<tr>
<td><span class="style2">Email:</span> not shown</td>
<td><input name="email" type="text" id="email" size="30" /></td>
</tr>
<tr>
<td><span class="style2">Tel:</span></td>
<td><input name="tel" type="text" id="tel" size="15" /></td>
</tr>
<tr>
<td><span class="style2">Lost/Found:</span></td>
<td><select name="state">
<option value="lost">LOST</option>
<option value="found">FOUND</option>
</select>
<br /></td>
</tr>
<tr>
<td><span class="style2">Dog/Cat:</span></td>
<td><select name="type">
<option value="dog">Dog</option>
<option value="cat">Cat</option>
</select>
<br /></td>
</tr>
<tr>
<td><span class="style2">Area: Found or Lost</span></td>
<td><input name="area" type="text" id="area" size="30" /></td>
</tr>
<tr>
<td valign="top"><span class="style2">Description:</span></td>
<td><textarea name="desc" cols="30" rows="6" id="desc"></textarea></td>
</tr>
<tr>
<td>Photo: Rename your photo to see below</td>
<td><input type="file" name="pic" /></td>
</tr>
<tr>
<td>Anti-Spam Question. How many legs on a Dog ?</td>
<td><input name="leg" type="text" id="leg" size="3" /></td>
</tr>
<tr>
<td>Picture Number as below if no pic then enter 1 for dog 2 for cat</td>
<td><input name="pnum" type="text" id="pnum" size="3" /></td>
</tr>
<tr>
<td><input name="send" type="submit" id="send" onclick="MM_validateForm('name','','R','email','','NisEmail','tel','','RisNum','area','','R','desc','','R');return document.MM_returnValue" value="Send" /></td>
</tr>
</table>
</form>
</div>
many thanksPHP Code://This gets all the other information from the form
$state=$_POST['state'];
$type=$_POST['type'];
$area=$_POST['area'];
$desc=$_POST['desc'];
$name=$_POST['name'];
$email=$_POST['email'];
$tel=$_POST['tel'];
$pnum=$_POST['pnum'];
$date = date("d-m-Y");
$pname=$pnum.".jpg";
// Connects to your Database
$dbh=mysql_connect("localhost", "vcd", "57") or die('I cannot connect to database because: ' .mysql_error()) ;
mysql_select_db("pets");
//Writes the information to the database
mysql_query("INSERT INTO `register` VALUES ('$id', '$state', '$type', '$area', '$desc', '$name', '$email', '$tel', '$pname', '$date')");
//compose the mail message
$msg= "New Record\n Region: $region, Name: $name, Email: $email ";
//send the mail
mail('d@gmail.com','New Record',$msg)
?>
Doug






Bookmarks