hello guyz,..magpa help lng ko about sa akong ghimo na site,..php akong gigamit sa site,ug may connection sya sa image..Ok na ang uploader sa akong site ug ma-view na kni after ma-save pero may big problem ko coz if ang user gusto nya mag change another picture dra na nag sugod ang problem nko mag consumed man gud sad sya ug laing field sa akong database tpus the same file name..
mao ni akong source code
<?php
session_start();
include 'dbcon.php';
$email=$_SESSION['user'];
$iquery="SELECT image FROM tbl_client WHERE email='$email'";
$iresult=mysql_query($iquery) or die ("ERROR ME");
function is_valid_type($file)
{
// This is an array that holds all the valid image types
$valid_types = array("image/jpg", "image/jpeg", "image/bmp", "image/gif");
if (in_array($file['type'], $valid_types))
return 1;
return 0;
}
$TARGET_PATH = "upload/";
$image = $_FILES['image'];
$email=$_POST['email'];
$image['name'] = mysql_real_escape_string($image['name']);
$TARGET_PATH .= $image['name'];
if (move_uploaded_file($image['tmp_name'], $TARGET_PATH))
{
$sql = "insert into tbl_client values (id, '" . $image['name'] . "', '$email')";
$result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
?>
<script type="text/javascript">
alert("YOU HAVE BEEN UPLOADED YOUR PICTURE");
</script>
<?php
}
if(file_exists($TARGET_PATH))
{
move_uploaded_file($image['tmp_name'], $TARGET_PATH);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#form1 table tr td table tr td div a {
color: #000;
}
-->
</style>
</head>
<center><body background="Images/Background.gif">
<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="437" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19%" height="71"> </td>
<td width="57%"> </td>
<td width="24%"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="39"> </td>
<td><div align="center"><a href="membermain.php?email=<?php echo $_GET['email'];?>">HOME</a> | PROFILE | <a href="barangayclearance.php?email=<?php echo $_GET['email'];?>">BARANGAY CLEARANCE</a> | <a href="contactusmember.php?email=<?php echo $_GET['email'];?>">CONTACT US</a></div></td>
<td> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" height="318"> </td>
<td width="40%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" align="left"><strong>UPLOAD IMAGE HERE
<label></label>
<label></label>
<label></label>
<input name="email" type="text" id="email" size="30" readonly="readonly" value="<?php echo $_GET['email']; ?>" />
</strong></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="file" name="image" id="image" /> </td>
</tr>
<tr>
<td> </td>
<td><input name="MAX_FILE_SIZE" type="hidden" id="key" value="100000" /> <input name="submit" type="submit" id="submit" value="UPLOAD" /> <input name="submit1" type="reset" id="submit1" value="CANCEL" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">Note: If you have already uploaded a picture before, we advised that you need to delete the previous picture because it is a government site or else we will delete your account.</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="29%"> </td>
<td width="71%"> </td>
</tr>
</table></td>
</tr>
</table></td>
<td width="21%" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<?php
while($row=mysql_fetch_array($iresult,MYSQL_BOTH))
{
?>
<td><strong>Welcome:</strong></td>
<td rowspan="4" align="center" valign="top"><img src="upload/<?php echo $row['image'];?>" width="102" height="93" /></td>
</tr>
<?php
}
?>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="29%"><h5 align="center"> </h5></td>
<td width="71%"><div align="center"><?php echo $_GET['email'];?></div></td>
</tr>
<tr>
<td> </td>
<td><h5 align="center"><strong><a href="log-out.php">LOG-OUT</a></strong></h5></td>
</tr>
<tr>
<td> </td>
<td align="center"><h5><strong>Delete Photo</strong></h5></td>
</tr>
<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"> </td>
</tr>
</table></td>
</tr>
</table></td>
<td width="19%"> </td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>