Mini Shell

Direktori : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/new/fertilizer/
Upload File :
Current File : /var/www/vhosts/ccp.ac.th/smtp.ccp.ac.th/httpdocs/new/fertilizer/insert_sahakorn.php

<?php
    include 'db/database.php'; 
    $name_sahakorn = $_POST['name_sahakorn'];
   
 
 
    //เช็คชือซ้ำหรือไม่
    $sql_sahakorn = "SELECT name FROM sahakorn WHERE name ='$name_sahakorn'";
    $result_sahakorn = mysqli_query($link, $sql_sahakorn);
    $is_sahakorn = mysqli_num_rows($result_sahakorn);
    if ($is_sahakorn == 1) {
        header('Content-Type: application/json');
        $errors = "ชื่อสหกรณ์มีอยูแล้ว กรุณาเปลี่ยนชื่อสหกรณ์ใหม่" . mysqli_error($link);
        echo json_encode(array('status' => 'danger','message' => $errors));
        exit;
    }
    
  
    
    $sql = "INSERT INTO `sahakorn` (`name`) VALUES 
          ('$name_sahakorn')";
    $result = mysqli_query($link, $sql);
    
    if ($result) {
        header('Content-Type: application/json');
        echo json_encode(array('status' => 'success','message' => 'บันทึกข้อมูลเรียบร้อยแล้ว'));
    } else {
        header('Content-Type: application/json');
        $errors = "เกิดข้อผิดผลาดไม่สามารถบันทึกข้อมูลได้" . mysqli_error($link);
        echo json_encode(array('status' => 'danger','message' => $errors));
    }

Zerion Mini Shell 1.0