ok

Mini Shell

Direktori : /home2/selectio/www/tnpsctestbatch.com/api/
Upload File :
Current File : /home2/selectio/www/tnpsctestbatch.com/api/add_users.php

<?php

session_start();
include "../config/config.php"; 

if(isset($_POST['type']) && $_POST['type']=='create_user'){
         try{
             
            error_log("user Create is working");
            
            $name = $_POST['name'];
            $dob = $_POST['DOB'];
            $email = $_POST['email'];
            $mobile_no = $_POST['mobile_no'];
            $password = $_POST['password'];
            
       
            $statement = $pdo->prepare("INSERT INTO `tbl_students`(`name`,`dob`,`email`,`mobile_no`,`password`) VALUES (?,?,?,?,?)");   
            $result=$statement->execute(array($name,$dob,$email,$mobile_no,$password));
        
             
                   if($result){ 
                        $return_arr['message']='Registration Successfully...';
                        $return_arr['status']=200;
                    } 
                else{
                    $return_arr['message']='Something Went Wrong..';
                    $return_arr['status']=400;
                }
            
                }catch(Exception $e){
                    $return_arr['message']="$e";
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
    }
    


if(isset($_POST['type']) && $_POST['type']=='update_user'){
         try{

            $dob = $_POST['DOB'];
            $mobile_no = $_POST['mobile_no'];
            $password = $_POST['password'];
            $ids = $_POST['ids'];
            

            $statement = $pdo->prepare("UPDATE tbl_students SET `mobile_no`=?,`password`=?,`dob`=? WHERE `id`=? ");   
            $result=$statement->execute(array($mobile_no,$password,$dob,$ids));
        
             
                   if($result){ 
                        $return_arr['message']='Login Successfully...';
                        $return_arr['status']=200;
                    } 
                else{
                    $return_arr['message']='Something Went Wrong..';
                    $return_arr['status']=400;
                }
            
                }catch(Exception $e){
                    $return_arr['message']="$e";
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
    }
    
    

if(isset($_POST['type']) && $_POST['type']=='user_details_update'){
         try{
             
             error_log("ehfewi");
            $name = $_POST['name'];
            $email = $_POST['email'];
            $mobile_no = $_POST['mobile_no'];
             $dob = $_POST['dob'];
            $password = $_POST['password'];
            $ids = $_POST['ids'];
            

            $statement = $pdo->prepare("UPDATE tbl_students SET `name`=?,`email`=?,`mobile_no`=?,`password`=?,`dob`=? WHERE `id`=? ");   
            $result=$statement->execute(array($name,$email,$mobile_no,$password,$dob,$ids));
        
             
                   if($result){ 
                        $return_arr['message']='Your Details Successfully...';
                        $return_arr['status']=200;
                    } 
                else{
                    $return_arr['message']='Something Went Wrong..';
                    $return_arr['status']=400;
                }
            
                }catch(Exception $e){
                    $return_arr['message']="$e";
                    $return_arr['status']=500;
                }   
                echo json_encode($return_arr);
    }
    







if($_POST['type']=='add_subject_form'){
    error_log("inside if condition");
        try{

        //for($i=0;$i<count($_POST['question']);$i++){
            
        $subject = $_POST['subject'];
        
            
            $statement = $pdo->prepare("INSERT INTO `tbl_subject`(`subject_name`) VALUES (?)");                   
            
            $result=$statement->execute(array($subject));
        
        
        
            
           error_log();
            if($result){
             echo  '<script type="text/javascript">
                alert("New Placemnt Added successfully");
                window.location.href = "placement-details.php";
                </script>';
                unset($_POST);      
            }else{
              echo  '<script type="text/javascript">
                alert("Something went wrong try again...");
               window.location.href = "banner-add.php";
                </script>';
            }  
        }catch(Exception $e){
            $error=$e;
        }     
    }
    
    
// Exam Type Add Api Start Here    
    
    if($_POST['type']=='add_exam_type_form'){
        try{

        //for($i=0;$i<count($_POST['question']);$i++){
            
        $exam_type = $_POST['exam_type'];
        
            
            $statement = $pdo->prepare("INSERT INTO `mock_exam_type`(`exam_type`) VALUES (?)");                   
            
            $result=$statement->execute(array($exam_type));
        
        
        
            
           error_log();
            if($result){
             echo  '<script type="text/javascript">
                alert("Exam Type Added successfully");
                window.location.href = "exam-type-list.php";
                </script>';
                unset($_POST);      
            }else{
              echo  '<script type="text/javascript">
                alert("Something went wrong try again...");
               window.location.href = "mock-exam-type-add.php";
                </script>';
            }  
        }catch(Exception $e){
            $error=$e;
        }     
    }
    
// Exam Type Add Api Ends Here   


if($_POST['type']=='login_form'){
        try{
        $error_message='';
      
                    if(empty($_POST['email']) || empty($_POST['password'])) {
                        $error_message = 'Email or Password can not be empty';
                    } 
                    else {
                		
                		$email = strip_tags($_POST['email']);
                		$password = strip_tags($_POST['password']);
                
                    	$statement = $pdo->prepare("SELECT * FROM tbl_students WHERE email=? AND password=?");
                    	$statement->execute(array($email,$password));
                        $result = $statement->fetchAll(PDO::FETCH_ASSOC);    
                        $total = $statement->rowCount(); 
                            if($total==0) {
                                $return_arr['warning']=' <span style="color:red;">Email does not match</span>';
                                $return_arr['status']=200;
                                }
                        else{
                                $error_message = 'is working';
                                $_SESSION['user_exam'] = $result[0];
                                $return_arr['message']='Login Success';
                                $return_arr['status']=400;
                            } 
                                    
                                }
                    }catch(Exception $e){
                        $error=$e;
                    }  
                    
                     echo json_encode($return_arr);
            }
    
    


?>

Zerion Mini Shell 1.0