
PK 
<?php
include_once('../include/common.php');
include_once('../include/connection.php');
/*echo '<pre>';
print_r($_POST);
echo '</pre>';*/
$imgName = $_FILES['img']['name'];
$tmpName = $_FILES['img']['tmp_name'];
$sqlSelectForImg="SELECT * FROM user order by id desc";
$sqlQueryForImg=mysql_query($sqlSelectForImg);
$sqlFetchForImg=mysql_fetch_array($sqlQueryForImg);
if($_POST['action']=="edit") {
$sqlSelectForImgDel="SELECT * FROM user WHERE id=".$_POST['id'];
$sqlQueryForImgDel=mysql_query($sqlSelectForImgDel);
$sqlFetchForImgDel=mysql_fetch_array($sqlQueryForImgDel);
//echo $sqlFetchForImgDel['imgName'];
$unlink = "images/".$sqlFetchForImgDel['imgName'];
@unlink($unlink);
$imageNew = $_POST['id'].$sqlFetchForImg['id'].$imgName;
} else {
$imageNew = $sqlFetchForImg['id'].$imgName;
}
@mkdir ("images");
@move_uploaded_file($tmpName,"images/".$imageNew);
$name = $_POST['name'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$contact = $_POST['contact'];
$street = $_POST['street'];
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$veryfyPass = base64_encode($_POST['veryfyPass']);
if($_POST['action']=="add") {
$sqlSelectForReg="INSERT INTO user (name,gender,dob,contact,street,country,state,city,email,pass,veryfyPass,type)
VALUES ('".$name."','".$gender."','".$dob."','".$contact."','".$street."','".$country."',
'".$state."','".$city."','".$email."','".$pass."','".$veryfyPass."','".user."')";
$sqlQueryForReg=mysql_query($sqlSelectForReg);
if($_GET['type']=='admin'){
header('location: ../admin/user_detail/list.php');
} else {
header('location: ../index1.php');
}
}
if($_POST['action']=="edit") {
$sqlUpdateForReg="UPDATE user
SET name,gender,dob,contact,street,country,state,city,email,pass,veryfyPass,type
name='".$name."',
gender='".$gender."',
dob='".$dob."',
contact='".$contact."',
street='".$street."',
country='".$country."',
state='".$state."',
city='".$city."',
email='".$email."',
pass='".$pass."',
veryfyPass='".$veryfyPass."'
WHERE id=".$_POST['id'];
$sqlQueryForReg=mysql_query($sqlUpdateForReg);
if($_GET['action']=='admin'){
header('location: ../admin/user_detail/list.php');
} else{
header('location: ../user/indexu.php');
}
}
if($_GET['action']=="delete") {
$sqlSelectForImgDel="SELECT * FROM user WHERE id=".$_GET['id'];
$sqlQueryForImgDel=mysql_query($sqlSelectForImgDel);
$sqlFetchForImgDel=mysql_fetch_array($sqlQueryForImgDel);
$unlink = "images/".$sqlFetchForImgDel['imgName'];
@unlink($unlink);
$sqlDeleteForReg="DELETE FROM user
WHERE id=".$_GET['id'];
$sqlQueryForReg=mysql_query($sqlDeleteForReg);
header('location: ../admin/user_detail/list.php');
}
?>


PK 99