2.1 Admin Update
2.1 Admin Update
include("../include/config.php");
header('Location: index.php');
} else{
/* %%%%%%%%%%%%% START CODE SUBMIT %%%%%%%%%%%% */
$adminId = $_GET['id'];
$loginName = $_SESSION['userName'];
$loginId = $_SESSION['userId'];
$power = $_SESSION['adminType'];
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>';
}
//Email Condition
if( isset($_POST['email']) && !empty($_POST['email']) ){
$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]
+)*(\.[a-z]{2,3})$/";
if(preg_match($pattern,$_POST['email'])){
$cemail = 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>';
}
//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{
if(strlen($_POST['password']) < 6){
}else{
$message_c_pass = '<b class="text-danger text-center">Please
fill the confirm password field field</b>';
}
$uploadOk = 1;
} else {
$message_picture = '<b class="text-danger">File is not an
image</b>';
$uploadOk = 0;
}
} else {
$message_picture = '<b class="text-danger">Sorry, there
was an error uploading your file';
}
}
}else{
$newfilename = $_POST['picValue'];
$del = 'no';
}
// Submission
if( ( isset($name) && !empty($name) ) && ( isset($admin_type) && !
empty($admin_type) ) && ( isset($email) && !empty($email) ) && ( isset($password)
&& !empty($password) ) && ( isset($newfilename) && !empty($newfilename) ) ){
if($del == 'yes'){
$base_directory = "images/admin/";
if(unlink($base_directory.$_POST['picValue']))
$delVar = " ";
}
header('Location: home.php?back=2');
}else{
$submit_message = '<div class="alert alert-danger">
<strong>Warning!</strong>
You are not able to signup please try later
</div>';
}
}
}
}//submit button
if(isset($_GET['id'])){
$result = mysqli_query($connection,$query);
$adminPic = $row["profilePic"];
$adminName = $row["name"];
$adminMail = $row["admin_mail"];
$adminType = $row["type"];
}
}
}else header('Location: home.php?back=1');
include('header.php');