public static function create_table($name) { $query_string = "CREATE TABLE IF NOT EXISTS " . $name . "_questions" . "(\n\t\t\t\t\t\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `question` text NOT NULL,\n\t\t\t\t\t\t\t `option1` text NOT NULL,\n\t\t\t\t\t\t\t `option2` text NOT NULL,\n\t\t\t\t\t\t\t `option3` text NOT NULL,\n\t\t\t\t\t\t\t `option4` text NOT NULL,\n\t\t\t\t\t\t\t `correct_ans` text NOT NULL,\n\t\t\t\t\t\t\t `marks` int(11) NOT NULL,\n\t\t\t\t\t\t\t `negative_marks` int(11) NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t)"; $db = new DB_CONNECT(); $result = $db->query_database($query_string); return $result; }
public static function create_table($name) { $query_string = "CREATE TABLE IF NOT EXISTS " . $name . "_users " . "(\n\t\t\t\t\t\t\t `first_name` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t `last_name` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t `email` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t `phone_number` varchar(13) NOT NULL,\n\t\t\t\t\t\t\t `score` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t `questions_attempted` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t `correct_ans` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t `wrong_ans` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t PRIMARY KEY (`email`),\n\t\t\t\t\t\t\t UNIQUE KEY `phone_number` (`phone_number`)\n\t\t\t\t\t\t\t)"; $db = new DB_CONNECT(); $result = $db->query_database($query_string); return $result; }
public function __construct() { $DB_CONNECT = new DB_CONNECT(); $this->connection = new \mysqli($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword(), $DB_CONNECT->getName()); if ($this->connection->connect_errno) { echo "Failed to connect to MySQLI: " . $this->connection->connect_error; } }
public function __construct() { try { $DB_CONNECT = new DB_CONNECT(); $this->databaseConnection = mysql_connect($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword()) or die("Unable to connect to MySQL"); $this->selectedDatabase = mysql_select_db($DB_CONNECT->getDatabase(), $this->databaseConnection) or die("Could not select database"); } catch (Exception $error) { echo 'Caught exception: ', $error->getMessage(), "\n"; } }
function getProductes($id) { //Ens connectem a la base de dades require_once '../db_connect.php'; /*Creem la connexió*/ $db = new DB_CONNECT(); $con = $db->connect(); $productes = array(); $sql = "SELECT * FROM nfc_producte WHERE Id_categoria='{$id}'"; $query = mysqli_query($con, $sql); while ($producte = mysqli_fetch_assoc($query)) { $productes[] = $producte; } return json_encode($productes); $db->close($con); }
function getAllCategories() { //Ens connectem a la base de dades require_once 'db_connect.php'; /*Creem la connexió*/ $db = new DB_CONNECT(); $con = $db->connect(); $categories = array(); $sql = "SELECT * FROM nfc_categoria ORDER BY id_categoria"; $query = mysqli_query($con, $sql); while ($categoria = mysqli_fetch_assoc($query)) { $categories[] = $categoria; } return json_encode($categories); $db->close($con); }
<?php //make database connection require_once __DIR__ . '/db_connect.php'; $db = new DB_CONNECT(); $conn = $db->connect(); //initializing response array $response = array(); //default city value for testing web without android post $cityRetrived = "toronto"; //get post data city if (isset($_GET["city"])) { $cityRetrived = $_GET['city']; require_once __DIR__ . '/APICalls.php'; //sql query for current conditions $result2 = $conn->query("SELECT * FROM `currentConditions` WHERE city = '{$cityRetrived}'"); //check for empty data if (!empty($result2)) { if ($result2->num_rows > 0) { //getting row array from database $result2 = mysqli_fetch_array($result2); //storing row into data arrary $data = array(); $data["city"] = $result2["city"]; $data["temp"] = $result2["temp"]; $data["apparantTemp"] = $result2["apparantTemp"]; $data["summary"] = $result2["summary"]; $data["icon"] = $result2["icon"]; $data["time"] = $result2["time"]; $data["pressure"] = $result2["pressure"]; $data["dewPoint"] = $result2["dewPoint"];
{ "phonenumber":"8950683510"; }, { "phonenumber":"8950683512"; }, { "phonenumber":"8950683543"; } ] } */ require_once "includes/db_connect.php"; require_once "includes/functions.php"; $response = array(); $db = new DB_CONNECT(); // To count how many number are added in the table family $count = 0; if (isset($_POST["contacts"]) && isset($_POST["id"])) { // fecthing the json string encoded from the url and decoding it into the json array //$json = json_decode($_POST["contacts"],true); $phonearrays = decode_JSON($_POST["contacts"]); $id = $_POST["id"]; $number = array(); $response["phonenumbers"] = array(); foreach ($phonearrays as $number) { // convert the number $original_number = $number["phonenumber"]; if ($original_number[0] == '0') { $number = substr($original_number, 1); $original_number = "+91" . $number;
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/db/db_connect.php'; if (isset($_POST["login"]) && isset($_POST["password"])) { $db = new DB_CONNECT(); $login = $_POST["login"]; $password = $_POST["password"]; $response = array(); $login = $_POST["login"]; $result = $db->getConnection()->query("SELECT * FROM users WHERE login = '******'"); if (!empty($result)) { if ($result->num_rows > 0) { $result = $result->fetch_array(); $salt = $result["salt"]; $hash = md5(md5($password . md5(sha1($salt)))); $iterations = 10; for ($i = 0; $i < $iterations; ++$i) { $hash = md5(md5(sha1($hash))); } if ($hash == $result["password"]) { $response["success"] = 1; $response["user"] = array(); $response["user"]["first_name"] = $result["first_name"]; $response["user"]["last_name"] = $result["last_name"]; } else { $response["success"] = 0; $response["salt"] = $salt; $response["password"] = $hash; $response["message"] = "Wrong password"; } echo json_encode($response);
function getTaulaProductsCarrito() { session_start(); $productes_afegits = array(); $carrito = "<table id=\"taula_carrito\">"; $array_productes = explode(",", $_SESSION['carro']); $carrito .= "<tr>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">IMATGE</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">NOM</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">PREU (c/u)</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">PREU TOTAL</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">MODIFICAR</p>"; $carrito .= "</td>"; $quantitat_productes = 0; $preu_total = 0; foreach ($array_productes as $producte) { if ($producte != "") { $id_producte = substr($producte, 0, strpos($producte, "/")); $id_producte = trim($id_producte, "["); if (!in_array($id_producte, $productes_afegits)) { //Ens connectem a la base de dades require_once '../db_connect.php'; /*Creem la connexió*/ $db = new DB_CONNECT(); $con = $db->connect(); $sql = "SELECT * FROM nfc_producte WHERE id_producte = " . $id_producte . ";"; $query = mysqli_query($con, $sql) or die(mysqli_error($con)); $row = mysqli_fetch_array($query); $carrito .= "<tr>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<img class=\"element_taula\" width=\"100\" height=\"100\" src=\"../" . $row["URL_imatge"] . "\" onclick=\"removeFromCart(" . $id_producte . ")\"/>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $nom_producte = substr($producte, strpos($producte, "/") + 1, strpos($producte, "]")); $nom_producte = trim($nom_producte, "]"); $carrito .= "<p class=\"element_taula\">" . $nom_producte . " (x" . count(preg_grep($producte, $array_productes)) . ")</p>"; $productes_afegits[] = $id_producte; $carrito .= "</td>"; $quantitat_productes += count(preg_grep($producte, $array_productes)); $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula\">" . $row["Preu_IVA"] . "</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula\">" . $row["Preu_IVA"] * count(preg_grep($producte, $array_productes)) . "</p>"; $carrito .= "</td>"; $preu_total += $row["Preu_IVA"] * count(preg_grep($producte, $array_productes)); $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<img class=\"element_taula\" src=\"../resources/img/delete-product.png\" onclick=\"borrar(" . $id_producte . ");\"/>"; $carrito .= "</td>"; $carrito .= "</tr>"; } } } $carrito .= "<tr>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula header_taula\">TOTAL</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula\">" . $quantitat_productes . " unitats</p>"; $carrito .= "</td>"; $carrito .= "<td>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<p class=\"element_taula\">" . $preu_total . " euros</p>"; $carrito .= "</td>"; $carrito .= "<td id=\"fila_carrito\">"; $carrito .= "<button class=\"element_taula\">CONFIRMAR</button>"; $carrito .= "</td>"; $carrito .= "</table>"; return $carrito; }
<?php require_once "/includes/session.php"; require_once "/includes/db_connect.php"; require_once "/includes/functions.php"; confirm_logged_in(); $db = new DB_CONNECT(); if (isset($_POST["calamity"]) && isset($_POST["before_cal"]) && isset($_POST["after_cal"]) && isset($_POST["during_cal"])) { $calamity = trim($db->mysql_prep($_POST["calamity"])); $before_cal = trim($db->mysql_prep($_POST["before_cal"])); $after_cal = trim($db->mysql_prep($_POST["after_cal"])); $during_cal = trim($db->mysql_prep($_POST["during_cal"])); if (strlen($calamity) != 0 && strlen($before_cal) && strlen($after_cal) && strlen($during_cal)) { $queryString = "INSERT INTO guidelines ( calamity , during_cal, after_cal , before_cal ) VALUES( '{$calamity}','{$during_cal}','{$after_cal}' ,'{$before_cal}') "; echo $queryString; $result = $db->query_db($queryString); if ($result) { //$_POST["message"] = "Inserted to the database"; redirect_to("guidelines.php?message=Inserted to the database"); } else { echo "Cannot be inserted"; } } else { redirect_to("guidelines.php?message=Cannot be inserted. Some Values are Missing"); } } else { echo "Problem in the post request"; }
/* * Following code will create a new product row * All product details are read from HTTP Post Request */ // array for JSON response $response = array(); // check for required fields if (isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])) { $name = $_POST['name']; $price = $_POST['price']; $description = $_POST['description']; // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); $con = $db->getConnection(); // mysql inserting a new row $result = mysqli_query($con, "INSERT INTO products(name, price, description) VALUES('{$name}', '{$price}', '{$description}')") or die(mysqli_error($con)); // check if row inserted or not if ($result) { // successfully inserted into database $response["success"] = 1; $response["message"] = "Product successfully created."; // echoing JSON response echo json_encode($response); } else { // failed to insert row $response["success"] = 0; $response["message"] = "Oops! An error occurred."; // echoing JSON response
<?php /* * Following code will list all the items */ // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/php_includes/DB_CONNECT.php'; // connecting to db $db = new DB_CONNECT(); // get all items from item table $result = mysqli_query($db->connect(), "SELECT *FROM item ORDER BY RAND()") or die(mysql_error()); // check for empty result if (mysqli_num_rows($result) > 0) { // looping through all results // item node $response["items"] = array(); while ($row = mysqli_fetch_array($result)) { // temp user array $item = array(); $item["idItem"] = $row["idItem"]; $item["sub_category"] = $row["sub_category"]; $item["category"] = $row["category"]; $item["shop"] = $row["shop"]; $item["user"] = $row["user"]; $item["item_name"] = $row["item_name"]; $item["price"] = $row["price"]; $item["item_image"] = $row["item_image"]; // push single product into final response array array_push($response["items"], $item);
<?php require_once __DIR__ . '/db_connect.php'; $db = new DB_CONNECT(); $output['deals'] = array(); $db->connect(); $q = mysql_query("SELECT * from deals"); while ($row = mysql_fetch_array($q)) { $temp = array(); $temp['id'] = $row['id']; $temp['name'] = $row['name']; $temp['desc'] = $row['description']; $temp['expire_time'] = $row['expire_time']; $temp['brand_id'] = $row['brand_id']; $temp['img'] = $row['image']; array_push($output['deals'], $temp); } header('Content-Type: application/json'); print json_encode($output); mysql_close();
$response = array(); /*test data * $username = '******'; * $email = '*****@*****.**'; * $password = '******'; */ // check for required fields if (isset($_POST["username"]) && isset($_POST["email"]) && isset($_POST["password"]) && (!empty($_POST["username"]) && !empty($_POST["email"]) && !empty($_POST["password"]))) { $username = $_POST["username"]; $email = $_POST["email"]; $password = $_POST["password"]; $date = date("Y-d-m"); // include db connect class require_once __DIR__ . '/php_includes/DB_CONNECT.php'; // connecting to db $db = new DB_CONNECT(); $connection = $db->connect(); // mysql inserting a new row $result = mysqli_query($connection, "INSERT INTO user(username, email, password,date_joined) VALUES('{$username}', '{$email}', '{$password}','{$date}')"); $userId = mysqli_insert_id($connection); // check if row inserted or not if ($result) { // successfully inserted into database $response["userId"] = $userId; $response["success"] = 1; $response["message"] = "user registered successfully."; // echoing JSON response echo json_encode($response); } else { // failed to insert row $response["success"] = 0;
<?php /* * Following code will delete a job from table * A job is identified by request id (jobid) */ // array for JSON response $response = array(); // check for required fields if (isset($_POST['jobid'])) { // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $con = new DB_CONNECT(); $jobid = safe($con->getlink(), $_POST['jobid']); // mysql update row with matched jobid $result = mysqli_query($con->getlink(), "DELETE FROM roster WHERE jobid = '{$jobid}'"); // check if row deleted or not if ($result) { // successfully updated $response["success"] = 1; $response["message"] = "Job successfully deleted"; // echoing JSON response echo json_encode($response); } else { // no job found $response["success"] = 0; $response["message"] = "No job found"; // echo no users JSON echo json_encode($response); }
<?php $_POST = json_decode(file_get_contents('php://input'), true); if (isset($_POST["email"]) && isset($_POST['text'])) { require_once __DIR__ . './db_connect.php'; $id = $_POST["email"]; $tweet = $_POST['text']; //./db_connect file has class $db = new DB_CONNECT(); $db_c = $db->connect(); $qry = $db_c->prepare("INSERT INTO tweets(idtemail,tweet) VALUES (?,?)"); // fist argument tells format of each parameter $qry->bind_param("ss", $id, $tweet); $qry->execute(); $qry->close(); $db_c->close(); } else { echo "POST ELEMENTS NOT SET!"; }
<?php require_once "../includes/db_connect.php"; require_once "../includes/functions.php"; require_once "../includes/session.php"; confirm_logged_in(); if (!is_null($_GET['question_id'])) { $test_name = urldecode($_GET['test_name']); $question_id = $_GET["question_id"]; $db = new DB_CONNECT(); $username = get_username(); //$test_name = $db->mysql_prep($_POST["test_name"]); $table_name = $test_name . "_questions"; $query = "DELETE FROM " . $table_name . " WHERE id='{$question_id}'"; $result = $db->query_database($query); if (is_null($result)) { // query failed echo "query failed"; } else { redirect_to('question_list.php?test_name={$test_name}'); } }
<?php require_once '../includes/db_connect.php'; require_once '../includes/functions.php'; require_once '../includes/session.php'; confirm_logged_in(); $db = new DB_CONNECT(); // get username from the session $username = get_username(); //select all test created by him from test table if (isset($_GET["message"])) { $message = "The Test has been deleted."; } $query = "SELECT test_name,start_time,end_time,event_date,duration FROM test WHERE username='******'"; $admin_tests = $db->query_database($query); if ($db->number_of_rows($admin_tests) > 0) { $i = 1; while ($row = $db->fetch_array($admin_tests)) { $table_data = array(); $table_data_array[$i] = array(); $table_data["test_name"] = $row["test_name"]; $table_data["start_time"] = $row["start_time"]; $table_data["end_time"] = $row["end_time"]; $table_data["event_date"] = $row["event_date"]; $table_data["duration"] = $row["duration"]; $table_data_array[$i] = $table_data; $i++; } $no_of_rows = $i - 1; $table_data_array["number_of_rows"] = $no_of_rows; $table_html = make_test_information_table();
<?php /* * Following code will get single job details * A job is identified by job id (jobid) */ // array for JSON response $response = array(); // check for post data if (isset($_GET['jobid'])) { // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $con = new DB_CONNECT(); $jobid = safe($con->getlink(), $_GET['jobid']); // get a job from products table $result = mysqli_query($con->getlink(), "SELECT * FROM roster WHERE jobid = '{$jobid}'"); if (!empty($result)) { // check for empty result if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_array($result); $job = array(); $job["jobid"] = $row["jobid"]; $job["jobstatus"] = $row["jobstatus"]; $job["comments"] = $row["comments"]; // user node $response["job"] = array(); array_push($response["job"], $job); // success $response["success"] = 1; // echoing JSON response
<?php /* * Following code will get single item details * An item is identified by item id (idItem) */ // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/php_includes/DB_CONNECT.php'; // connecting to db $db = new DB_CONNECT(); // check for post data if (isset($_GET["itemid"])) { $idItem = $_GET["itemid"]; // get a product from products table $result = mysqli_query($db->connect(), "SELECT *FROM item WHERE idItem = {$idItem}"); if (!empty($result)) { // check for empty result if (mysqli_num_rows($result) > 0) { $result = mysqli_fetch_array($result); $item = array(); $item["idItem"] = $result["idItem"]; $item["sub_category"] = $result["sub_category"]; $item["shop"] = $result["shop"]; $item["user"] = $result["user"]; $item["item_name"] = $result["item_name"]; $item["price"] = $result["price"]; $item["item_image"] = $result["item_image"]; $item["description"] = $result["description"]; // success
$query = "UPDATE test SET test_name='{$test_name}', username='******',start_time='{$start_time}',\n end_time='{$end_time}',event_date='{$event_date}',duration='{$duration}' WHERE test_name='{$test_name}' "; $result = $db->query_database($query); if (is_null($result)) { // query failed echo "query failed"; } else { redirect_to("question_list.php?test_name=" . get_test_name()); } } else { echo "empty fields"; } } else { echo "Someting was not set"; } } else { $db = new DB_CONNECT(); $query = "SELECT * FROM test WHERE test_name='" . get_test_name() . "' AND username='******' "; $details = $db->query_database($query); if ($db->number_of_rows($details) > 0) { $i = 1; $row = $db->fetch_array($details); $table_data = array(); $table_data["test_name"] = $row["test_name"]; $table_data["start_time"] = $row["start_time"]; $table_data["end_time"] = $row["end_time"]; $table_data["event_date"] = $row["event_date"]; $table_data["duration"] = $row["duration"]; } } ?>
<?php // including the some files require_once "includes/db_connect.php"; // making the object of DB // response array for the JSON $response = array(); $db = new DB_CONNECT(); if (isset($_POST["longitude"]) && isset($_POST["latitude"])) { $longitude = $_POST["longitude"]; $latitude = $_POST["latitude"]; // Change that we have to make in the long. and lat. for the DB query $change = 0.05; // making the query $result = query_coordinates($longitude, $latitude, $change); if ($db->number_of_rows($result) > 0) { // getting and setting the coordinates in the response array get_the_coordinates($result); $response["success"] = 1; echo json_encode($response); } else { // no coordinates found for the specified location $response["success"] = 0; $response["message"] = "There are no coordinates in the DB for this location"; echo json_encode($response); } } else { // parameters are not set for the post request $response["success"] = 2; $response["message"] = "The logitude and latitudes are not set"; echo json_encode($response);
$response["success"] = -1; $response["errors"] = array(); if (isset($_POST["url"])) { if (preg_match('/\\s/', $_POST["url"])) { } require_once __DIR__ . '/db_connect.php'; $_ID = $_SESSION["session_name"]; $url = $_POST["url"]; if ($url == "./maps" || $url == "./vizs") { $response["success"] = 1; $response["redirect"] = "./modules/" . stripslashes($url); echo json_encode($response); exit; } // $url=addslashes($url); $db = new DB_CONNECT(); $db_c = $db->connect("userdata"); if ($url == "./p2p_ecommerce") { $qry = $db_c->prepare("SELECT * from hw_users where user_id=?"); // fist argument tells format of each parameter $qry->bind_param("s", $_ID); $qry->execute(); $result = $qry->get_result(); // echo $_ID; if (mysqli_num_rows($result) == 1) { $row = mysqli_fetch_array($result); if ($row['isadmin'] == 1) { $_SESSION['hw_user_chk'] = 1; } } }
<?php $response = array(); if (isset($_GET['id_user'])) { require '..\\db_connect.php'; $db = new DB_CONNECT(); $mysqli = $db->connect(); $id_user = $_GET['id_user']; $result = $mysqli->query("SELECT *FROM purchase_history WHERE ID_USER= '******' ") or die(mysql_error()); if (mysqli_num_rows($result) > 0) { $response["purchase_history"] = array(); while ($row = mysqli_fetch_array($result)) { $history = array(); $history["ID"] = $row["ID"]; $history["ID_PRODUCT"] = $row["ID_PRODUCT"]; array_push($response["purchase_history"], $history); } $response["success"] = 1; echo json_encode($response); } else { $response["success"] = 0; $response["message"] = "No products found"; echo json_encode($response); } }
<?php /* * Following code will list all the products */ // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); echo "init db : creation tables"; $sql = "CREATE TABLE IF NOT EXISTS PRODUCTS (\npid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\nname VARCHAR(100) NOT NULL,\nprice DECIMAL(10,2) NOT NULL,\ndescription TEXT,\ncreated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\nupdated_at timestamp NULL DEFAULT NULL\n)"; if ($db->query($sql) === TRUE) { echo "Table Products created successfully"; } else { echo "Error creating table: " . $db->error; } $db->close();
<?php require_once "/includes/session.php"; require_once "/includes/db_connect.php"; require_once "/includes/functions.php"; $db = new DB_CONNECT(); $message = ""; // check and submit the user request for the access of the page if (isset($_POST["submit"])) { $user_id = trim($db->mysql_prep($_POST["username"])); $password = trim($db->mysql_prep($_POST["password"])); $hashed_password = sha1($password); // for the hashing of the password $queryString = "SELECT * FROM adminUser WHERE username='******' && password='******' "; $result = $db->query_db($queryString); if ($db->number_of_rows($result) > 0) { $_SESSION["username"] = $user_id; redirect_to("firstpage.php"); } else { $message = "Passowrd and Username combination is wrong"; } } ?> <html lang="en" class="no-js"> <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8"> <title>DISASTER SAFETY</title> <link rel="stylesheet" type="text/css" href="stylesheets/demo.css"> <link rel="stylesheet" type="text/css" href="stylesheets/style.css"> <link rel="stylesheet" type="text/css" href="stylesheets/animate-custom.css"> </head>
<?php // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); // get all products from products table $result = mysqli_query($db->connect(), "SELECT *FROM spt_user where userid=\"" . $_POST["userId"] . "\""); // check for empty result if (mysqli_num_rows($result) > 0) { // looping through all results // products node while ($row = mysqli_fetch_array($result)) { $response["username"] = $row["username"]; } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { $response["success"] = 0; $response["message"] = "No persons found"; echo json_encode($response); }
<?php $name = $_GET['name']; //$name = "Aster Hotel"; $response = array(); //echo $name; // include db connect class require_once __DIR__ . '/db_user_connect.php'; // connecting to db $con = new DB_CONNECT(); $con->connect(); //$sql ="SELECT category.catid, category.name as cat_name, information.id, information.name as info_name, information.* FROM category INNER JOIN information ON category.catid=information.cat_id WHERE information.name='$name'"; $sql = "SELECT category.catid, category.name as cat_name, information.id, information.name as info_name FROM category INNER JOIN information ON category.catid=information.cat_id WHERE information.name='{$name}'"; //echo $sql; $res = mysqli_query($con->myconn, $sql); $row = mysqli_num_rows($res); $row = mysqli_fetch_assoc($res); $table_name = $row['cat_name']; //echo $table_name; $sql = "SELECT {$table_name}.* , information.* FROM {$table_name} INNER JOIN information ON {$table_name}.info_id=information.id WHERE information.name='{$name}'"; //echo $sql; $res = mysqli_query($con->myconn, $sql); $row = mysqli_num_rows($res); if ($row > 0) { //echo "OL"; $response["detail"] = array(); while ($row = mysqli_fetch_assoc($res)) { //hotel (cat name_ $detail = array(); $detail["price_high"] = $row['price_high']; $detail["price_low"] = $row['price_low'];
<?php // including the some files require_once "includes/db_connect.php"; // making the object of DB // response array for the JSON $response = array(); $db = new DB_CONNECT(); // making the query $query_string = "SELECT * FROM news"; $result = $db->query_db($query_string); if ($db->number_of_rows($result) > 0) { // JSON news array $response["news"] = array(); while ($row = $db->fetch_array($result)) { // Setting the fileds $news = array(); $news["id"] = $row["id"]; $news["notification"] = $row["notification"]; $news["info"] = $row["info"]; $news["date"] = $row["date"]; array_push($response["news"], $news); } $response["success"] = 1; } else { // There is no news in the database $response["success"] = 0; $response["message"] = "There is no news in the in the table"; } // echoing the JSON response echo json_encode($response);