2 Admin
2 Admin
2 Admin
include("../include/config.php");
header('Location: index.php');
}else{
$loginName = $_SESSION['userName'];
$loginId = $_SESSION['userId'];
$power = $_SESSION['adminType'];
$alertMessage = " ";
if( isset($_POST['submit']) ){
$admin_type = $_POST["admin_op"];
} else {
$admin_error = '<b class="text-danger text-center">Please
select Admin Type option.</b>';
}
//Name Condition
if( isset($_POST['fullname']) && !empty($_POST['fullname'])){
if(preg_match('/^[A-Za-z\s]+$/',$_POST['fullname'])){
$name = mysqli_real_escape_string($connection,
$_POST['fullname']);
}else{
$message_name = '<b class="text-danger text-center">Please
type correct Name</b>';
}
}else{
$message_name = '<b class="text-danger text-center">Please
fill the Name field</b>';
}
if(preg_match($pattern,$_POST['email'])){
$cemail = mysqli_real_escape_string($connection,
$_POST['email']);
$email = mysqli_real_escape_string($connection,
$_POST['email']);
}
}else{
$message_email = '<b class="text-danger text-
center">Please type correct email</b>';
}
}else{
$message_email = '<b class="text-danger text-center">Please
fill email field</b>';
}//email if condition
//Password Condition
if(isset($_POST['c_password']) && !empty($_POST['c_password'])){
if($_POST['c_password'] != $_POST['password']){
$message_c_pass = '<b class="text-danger text-
center">Please write same password in both fields</b>';
}else{
$target_dir = "images/admin/";
$target_file = $target_dir . basename($_FILES["profilePic"]
["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
$check = getimagesize($_FILES["profilePic"]["tmp_name"]);
if($check !== false) {
$uploadOk = 1;
} else {
$message_picture = '<b class="text-danger">File is not an
image</b>';
$uploadOk = 0;
}
// Check file size
if ($_FILES["profilePic"]["size"] > 5000000) {
$message_picture = '<b class="text-danger">Sorry, your
file is too large.</b>';
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" &&
$imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
$message_picture = '<b class="text-danger">Sorry, only
JPG, JPEG, PNG & GIF files are allowed</b>';
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk != 0) {
$temp = explode(".", $_FILES["profilePic"]["name"]);
$newfilename =
mysqli_real_escape_string($connection,round(microtime(true)) . '.' . end($temp));
if (move_uploaded_file($_FILES["profilePic"]["tmp_name"],
$target_dir . $newfilename)) {
} else {
$message_picture = '<b class="text-danger">Sorry,
there was an error uploading your file';
}
}
}else{
$message_picture = '<b class="text-danger">Please Select Your
Profile picture</b>';
}
header('Location: home.php#end');
}else{
$submit_message = '<div class="alert alert-danger">
<strong>Warning!</strong>
You are not able to signup please try later
</div>';
}
}
} // end of if
}else{
if(isset($_GET['sucess'])){
if(isset($_GET['delid'])){
$deluser = $_GET['delid'];
if($power == 'yes'){
if ($deluser != 1) {
</form>
</div>";
} else {
$alertMessage = "<div class='alert alert-danger'>
<p>Please Chaudhry cannot Delete yourself <strong>THANK
YOU.</strong> </p><br>
<a type='button' class='btn btn-default btn-sm' data-
dismiss='alert'>Cancel</a>
</div>";
}
}else{
$alertMessage = "<div class='alert alert-danger'>
<p>You are not a Sophisticated Admin. So, You cannot right to delete
any Admin <strong>THANK YOU.</strong> </p><br>
<a type='button' class='btn btn-default btn-sm' data-
dismiss='alert'>Cancel</a>
</div>";
}
}
$back = $_GET['back'];
if($back!=2){
$update_status = "<div class='alert alert-danger'>
<p>You are not a Sophisticated Admin. You can update your own
record.<strong>THANK YOU.</strong> </p><br>
<a type='button' class='btn btn-default btn-sm' data-
dismiss='alert'>Cancel</a>
</div>";
}else{
$id = $_GET['id'];
if($result){
// redirect
header("Location: home.php?sucess=1");
} else {
echo "Error".$query."<br>".mysqli_error($conn);
}
}
include('header.php');