Example #1
0
function getConnection()
{
    global $dbConnection;
    $dbConnector = new DatabaseConnector();
    $dbConnection = $dbConnector->connect();
    if ($dbConnection == "Failed to connect") {
        return json_encode("Connection to the database has failed");
    } else {
        return json_encode("Connection successful");
    }
}
Example #2
0
<?php

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
include 'connectDatabase.php';
$connection = new DatabaseConnector();
$con = $connection->connect();
$response = array();
if ($con) {
    // Selecting database
    $database = mysql_select_db("leaf_me_alone");
    if ($database) {
        $select_query = "select * from leafs";
        $result = mysql_query($select_query) or die(mysql_error());
        if (!empty($result)) {
            if (mysql_num_rows($result) > 0) {
                $response["leafs"] = array();
                while ($row = mysql_fetch_array($result)) {
                    $leaf = array();
                    $leaf["id"] = $row["id"];
                    $leaf["location"] = $row["location"];
                    $leaf["defect_percentage"] = $row["defect_percentage"];
                    $leaf["time_stamp"] = $row["time_stamp"];
                    $leaf["salt_name"] = $row["salt_name"];
                    array_push($response["leafs"], $leaf);
                }
                $response["success"] = 1;
                echo json_encode($response);
            } else {
                $response["success"] = 0;
                $response["message"] = "No found";
Example #3
0
<?php

require_once 'php/DatabaseConnection.php';
$connect = new DatabaseConnector();
$connect->connect();
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS);
$country = $_POST['country'];
$state = $_POST['state'];
$city = $_POST['city'];
$accounttype = $_POST['accounttype'];
$email = $_POST['email'];
$password = $_POST['password'];
$hashedPass = md5($password);
if (isset($_POST)) {
    $sql = "INSERT INTO members VALUES('{$username}','{$country}','{$state}','{$city}','{$accounttype}','{$email}','{$hashedPass}', now())";
    $connect->getConnection()->query($sql);
    $id = $connect->insert_id;
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>Activation Tester | Rolando Moreno | Full Stack Web Developer</title>

        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
        <!-- Bootstrap -->