Iam just stuck on this code I want to add an water mark on in between this process but I don't know how to give it. If the user select upload on the first image the image will uploaded and it will show in the right side. I want to give water mark on each image while user uploading. Please help me if any one can correct this code it will be help full please add the right code in your reply below I have added all the code in that page.
<?php
session_start();
include_once('admin/connection.php');
include_once('functions.php');
include_once('m_loginfunctions.php');
if(checkLoggedin())
{
$uemail = mysql_real_escape_string($_SESSION['user_sincere']);
$upass = decode3t(mysql_real_escape_string($_SESSION['pass_sincere']));
}
else
{
header("Location: login.php");
}
$str="";$str2="";
$img_str="";$img_str2="";
$regno="";$pid="";
$phto0='';$phto1 ='';$phto2 ='';$phto3 ='';$phto4 ='';$phto5 ='';$phto6='';$phto7='';
$thumb_img="";$thumb_report="";$image_to_be_cropped="";$thumb_full="";
$selquery=mysql_query("select * from `pdetails` where `email`='$uemail' ") or die(mysql_error());
if(mysql_num_rows($selquery)==1)
{
$fet=mysql_fetch_array($selquery);
$regno=$fet['regno'];
$pid = $fet['pid'];
$phto0 = $fet['phto0'];
$phto1 = $fet['phto1'];
$phto2 = $fet['phto2'];
$phto3 = $fet['phto3'];
$phto4 = $fet['phto4'];
$phto5 = $fet['phto5'];
$phto6 = $fet['phto6'];
$phto7 = $fet['phto7'];//kalyana kuri mage
}
if( isset($_GET['phto']) && $_GET['phto']!='' )
{
$phto = $_GET['phto'];
switch($phto)
{
case 0: $query ="update `pdetails` set `phto0`='' where `pid`='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto0);
header("Location: photo.php");
}//deleted
break;
case 1: $query ="update `pdetails` set `phto1`='' where `pid`='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto1);
header("Location: photo.php");
}//deleted
break;
case 2: $query ="update pdetails set phto2='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto2);
header("Location: photo.php");
}//deleted
break;
case 3: $query ="update pdetails set phto3='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto3);
header("Location: photo.php");
}//deleted
break;
case 4: $query ="update pdetails set phto4='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto4);
header("Location: photo.php");
}//deleted
break;
case 5: $query ="update pdetails set phto5='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto5);
header("Location: photo.php");
}//deleted
break;
case 6: $query ="update pdetails set phto6='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto6);
header("Location: photo.php");
}//deleted
break;
//kalyana kuri image
case 7: $query ="update pdetails set phto7='' where pid='{$pid}' ";
mysql_query($query);
if(mysql_affected_rows()==1){
unlink("admin/images/".$phto7);
header("Location: photo.php");
}//deleted
break;
default: //do nothing
}//end switch
}
//image upload portion
for($i=0;$i<=7;$i++)
{
if(isset($_POST["add_phto$i"]) )
{
if( $_FILES["phto$i"]["name"]=='' )
{
$img_str = 'Please select image for upload.' ;
}
else if(
(
($_FILES["phto$i"]["type"] == "image/gif") ||
($_FILES["phto$i"]["type"] == "image/jpeg")||
($_FILES["phto$i"]["type"] == "image/pjpeg")
)
&&
($_FILES["phto$i"]["size"] < 1048576)//means 1 mb 1024 bytes =1 Kb, 1024 Kb =1 mb
)
{
if($_FILES["phto$i"]["error"]>0)
{
$img_str= "upload error(image $i)";
}
else
{
if($_FILES["phto$i"]["size"]!=0)
{
move_uploaded_file($_FILES["phto$i"]["tmp_name"],"admin/images/".$regno."_".$i.".jpg");
$phto =$regno."_".$i.".jpg";
$query = "update `pdetails` set `phto$i`='$phto' where `pid`='$pid' ";
$resultset= mysql_query($query);
if(mysql_affected_rows()==1)
{
//$img_str2="Image uploaded successfully";
header("Location:photo.php");
exit;
}
}
}
}
else
{
$img_str= "(Image: $i) - Incompatible format or size exceeded 1 Mb.";
}
}//end if
}//end for
?>
<!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" />
<link rel="stylesheet" type="text/css" href="css/basic.css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$('#country').change(function(){
$('#state').load('ajxcheck.php?cid='+$(this).val());
});
});
</script>
<title>Sincere Matrimony</title>
</head>
<body>
<?php include('header.php') ; ?>
<table width="950" border="0" cellspacing="0" cellpadding="0" class="inner_page" align="center">
<tr valign="top">
<td width="650" class="inner_contant">
<div class="user">
<?php include_once('user_menu.php') ; ?>
<div class="user_cont">
<table class="login" cellpadding="3" cellpadding="2" border="0">
<tr height="30"><td colspan="2"></td></tr>
<tr><td class="heading4" colspan="2">Add Photo</td></tr>
<tr><td colspan="2">
<?php
if($img_str!="")
{
echo '<div class="rep">'.$img_str.'</div>';
}
if($img_str2!="")
{
echo '<div class="success_rep">'.$img_str2.'</div>';
}
?>
</td></tr>
<tr>
<td class="td_p1" valign="top" >Thumb Image (150x150) </td>
<td class="td_p2">
<form name="form0" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto0" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto0" class="edit_phto_submit"/>
</form>
<?php if($phto0!=''){?>
<img src="admin/images/<?=$phto0?>" class="p_img"/>
<a href='photo.php?phto=0' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1" valign="top">Photo 1</td>
<td class="td_p2">
<form name="form1" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto1" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto1" class="edit_phto_submit"/>
</form>
<?php if($phto1!=''){?><img src="admin/images/<?=$phto1?>" class="p_img"/>
<a href='photo.php?phto=1' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1">Photo 2</td>
<td class="td_p2" valign="top">
<form name="form2" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto2" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto2" class="edit_phto_submit"/>
</form>
<?php if($phto2!=''){?><img src="admin/images/<?=$phto2?>" class="p_img" />
<a href='photo.php?phto=2' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1">Photo 3</td>
<td class="td_p2" valign="top">
<form name="form3" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto3" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto3" class="edit_phto_submit"/>
</form>
<?php if($phto3!=''){?><img src="admin/images/<?=$phto3?>" class="p_img" />
<a href='photo.php?phto=3' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1" valign="top">Photo 4</td>
<td class="td_p2">
<form name="form4" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto4" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto4" class="edit_phto_submit"/>
</form>
<?php if($phto4!=''){?><img src="admin/images/<?=$phto4?>" class="p_img" />
<a href='photo.php?phto=4' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1" valign="top">Photo 5</td>
<td class="td_p2">
<form name="form5" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto5" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto5" class="edit_phto_submit"/>
</form>
<?php if($phto5!=''){?><img src="admin/images/<?=$phto5?>" class="p_img" />
<a href='photo.php?phto=5' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr>
<td class="td_p1" valign="top">Photo 6</td>
<td class="td_p2">
<form name="form6" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto6" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto6" class="edit_phto_submit"/>
</form>
<?php if($phto6!=''){?><img src="admin/images/<?=$phto6?>" class="p_img" />
<a href='photo.php?phto=6' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr height="1">
<td colspan="2"><hr /></td>
</tr>
<tr>
<td class="td_p1" valign="top">Thalakuri </td>
<td class="td_p2">
<form name="form7" action="" method="post" enctype="multipart/form-data">
<input type="file" name="phto7" class="edit_phto_file"/>
<input type="submit" value="Upload" name="add_phto7" class="edit_phto_submit"/>
</form>
<?php if($phto7!=''){?><img src="admin/images/<?=$phto7?>" class="p_img" />
<a href='photo.php?phto=7' onClick="return confirm('Delete image ?')">
<img src="admin/web_images/delete.gif" class="d_img" /> </a>
<?php } ?>
</td>
</tr>
<tr height="30"><td colspan="2"></td></tr>
<tr>
<td class="td_p1"></td>
<td class="td_p2">
<a href="user.php" class="reg_link">Finish</a>
</td>
</tr>
</table>
</div>
</div>
<p> </p>
</td>
<td width="300" >
<?php include('searchform_side.php') ;?>
</td>
</tr>
</table>
<?php include('footer.php') ; ?>
</body>
</html>