API IN PHP INSERT AND THEN SELECT FROM DATABASE

Jyotishgher Astrology
By -
0

 API IN PHP INSERT AND THEN SELECT FROM DATABASE




<?php

  //importing dbConnect.php script 

 require_once('./dbConnectrcf.php');

//mysqli_set_charset($con, 'utf8');

/* check connection */

if (mysqli_connect_errno()) {

    printf("Connect failed: %s\n", mysqli_connect_error());

    exit();

}

//http://122.252.248.53:81/rcf/script_dataentry/visitor_entry.php?mobile_no=213223421&pass_no=124&visit_purpose=test&purpose_detail=test&id_type=Test&id_no=123&from_dt=12&to_dt=12&from_tm=12&to_tm=1&total_person=3&visit_department=IT&empno=026763

 



 $response = array();


  $pass_no = $_REQUEST['pass_no'];

  $mobile_no = $_REQUEST['mobile_no'];

  $visit_purpose = $_REQUEST['visit_purpose'];

  $purpose_detail = $_REQUEST['purpose_detail'];

  $id_type = $_REQUEST['id_type'];

  $id_no  = $_REQUEST['id_no'];


  $from_dt = $_REQUEST['from_dt'];

  $to_dt  = $_REQUEST['to_dt'];

  $from_tm = $_REQUEST['from_tm'];

  $to_tm = $_REQUEST['to_tm'];

  $total_person = $_REQUEST['total_person'];

$visit_department = $_REQUEST['visit_department'];


$ALLOTTEE_CODE_VALUES= $_REQUEST['empno'];



    $result = mysqli_query($con, "INSERT INTO visit_mas(

pass_no,

mobile_no,

visit_purpose,

purpose_detail,

    id_type,

id_no,

    from_dt,

    to_dt,

    from_tm,

    to_tm,

    total_person,

visit_department,

empno

VALUES ('$pass_no',

'$mobile_no',

'$visit_purpose',

'$purpose_detail',

'$id_type',

'$id_no',

'$from_dt',

'$to_dt',

'$from_tm',

'$to_tm',

'$total_person',

'$visit_department',

'$ALLOTTEE_CODE_VALUES'

)");



 

 

    $result = mysqli_query($con, "SELECT pass_no FROM visit_mas where mobile_no='$mobile_no' and empno='$ALLOTTEE_CODE_VALUES' ");


      $objResult = mysqli_fetch_assoc($result);

       


    if ($result== TRUE)

{


     

        $response["status"] = 1;

        $response["message"] = "added";


        $response["pass_no"] =$objResult["pass_no"];

   

        echo json_encode($response);

    } 

else 

{

        $response["status"] = 0;

        $response["message"] = "Try Again";

$response["pass_no"] =$objResult["pass_no"];

        echo json_encode($response);

    }

 


?>


OUTPUT LIKE:

{"status":1,"message":"added","pass_no":"132"}

Post a Comment

0Comments

Post a Comment (0)