Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Access-Control-Allow-Origin: *');
- header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
- header('Access-Control-Allow-Headers: Content-Type,x-prototype-version,x-requested-with');
- header('Cache-Control: max-age=900');
- header("Content-Type: application/json"); // tell client that we are sending json data
- $servername = "localhost";
- $username = "saurabh_adminv8";
- $password = "adminv8";
- $dbname = "saurabh_adminv8";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $id;
- $data = json_decode(file_get_contents('php://input'), true);
- if(!empty($data)) {
- $id= $data['id'];
- }
- if(!empty($_POST)) {
- $id = $_POST['id'];
- }
- // $sql = "SELECT template_id, template_name as name, template_demolink, template_pic, template_code2 FROM template_types where template_id = " . $id;
- $sql = "SELECT firstname, lastname, email, favjob FROM crudtable";
- $result = $conn->query($sql);
- $results = array();
- if (($result))
- {
- $row = $result->fetch_assoc();
- $result->free();
- echo('{"status":"SUCCESS", "Records": ' . json_encode($row) . '}');
- }
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment