<?php
mysql_connect("localhost","root","rootwdp");
mysql_select_db("associates") or die("unable to select");
if(isset($_POST["update"]))
{
$empid=$_POST['empid'];
$username=$_POST['uname'];
$dofjoin=$_POST['date'];
$design=$_POST['design'];
$exp=$_POST['exp'];
$contact=$_POST['contact'];
$pname=$_POST['pname'];
$photo=$_POST['userfile'];
if($_FILES['userfile']['size'] > 0)
{
$file_dir = "photos";
foreach($_FILES as $file_name => $file_array)
$fileName = $_FILES['userfile']['name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$tmpName = $_FILES['userfile']['tmp_name'];
$file_array;
$fileName = $empid.".jpg";
if (is_uploaded_file($file_array['tmp_name']))
{
$test=move_uploaded_file($file_array['tmp_name'],"$file_dir/$fileName") or die ("Couldn't copy");
}
}
if(@$test)
{
$photo=$file_dir."/".$fileName;
}
//echo "<img src='".$_SESSION['photopath']."'/>";
//echo "<a href='#' onclick='refreshParent()'>close</a>";
$remarks=$_POST['remarks'];
$query = "UPDATE `jos_employee` SET name='$username', designation='$design', date_of_joining='$dofjoin', experience='$exp', contact='$contact', remarks='$remarks' ";
if($test)
{
$query.= "photo_url ='$photo'";
}
else
{
}
$query.=" WHERE emp_id=$empid";
$run=mysql_query($query);
//header("Location:index.php?option=com_testingofupdatedelete&page=$currpage");
header("Location:index.php?option=com_completedetailsofassociate");
}?>
<?php
mysql_connect("localhost","root","rootwdp");
mysql_select_db("associates") or die("unable to select");
$id=$_GET['id'];
$query = "SELECT * FROM `jos_employee` WHERE emp_id='$id'";
$dd=mysql_query($query);
?>
<form action="" method="post" name="myform" enctype="multipart/form-data">
<table bgcolor="#CDE3EE" align="center" class="tablecls" >
<?php
while( $row=mysql_fetch_array($dd))
{
?>
<tr>
<td>Username : </td>
<td><input type="text" value="<?php echo $row[0];?>" name="uname" id="uname" /></td>
</tr>
<tr> <td>Emp Id : </td>
<td><input type="text" value="<?php echo $row[1];?>" name="empid" id="empid" /></td>
</tr>
<tr>
<td>Designation : </td>
<td> <input type="text" value="<?php echo $row[2];?>" name="design" id="design" /></td>
</tr>
<tr>
<td>Date Of Join : </td>
<td><input type="text" value="<?php echo $row[3];?>" name="date" id="date" /></td>
</tr>
<tr>
<td>Experience : </td>
<td> <input type="text" value="<?php echo $row[4];?>" name="exp" id="exp" /></td>
</tr>
<tr>
<td>Contact Number : </td>
<td><input type="text" value="<?php echo $row[5];?>" name="contact" id="contact" /></td>
</tr>
<tr><td>Photo</td>
<td colspan="2">
<img src="http://localhost/associates/<?php echo $row[6];?>" />
</td><td><input type="file" id="userfile" name="userfile" /></td></tr>
<tr>
<td>Remarks : </td>
<td> <input type="text" value="<?php echo $row[7];?>" name="remarks" id="remarks" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="update" id="update" value="Update"/> <input type="reset" id="reset" name="reset"></td>
</tr>
<?php } ?>
</table>