Ejemplo n.º 1
0
<?php

require_once "praveen.php";
$respjson = array("status" => "unprocessed", error => 1);
$keys = array("userid", "password", "repassword");
$prn = new praveen();
$password = $prn->safePost("password");
$repassword = $prn->safePost("repassword");
if ($prn->checkPOST($keys)) {
    if (strcmp($password, $repassword) == 0) {
        $con = $prn->getConnection();
        if ($con) {
            $userid = $prn->safePost("userid");
            $sql = "select password from registered_users where id='{$userid}' limit 1";
            if ($result = $prn->query($sql)) {
                $usercount = $result->num_rows;
                if ($usercount == 1) {
                    $sql = "update  hawabaaz.registered_users set password='******' where id='{$userid}'";
                    $prn->query($sql);
                    $respjson[error] = 0;
                    $respjson['status'] = "success";
                } else {
                    $respjson["status"] = "Authentication Failure";
                    $respjson[error] = 5;
                }
            } else {
                $respjson["status"] = "SQL querry error";
                $respjson["SqlError"] = $conn->error;
                $respjson[error] = 4;
            }
        } else {
Ejemplo n.º 2
0
<?php

require_once "praveen.php";
$keys = array("userId", "orders");
$app = new praveen();
$conn = $app->getConnection();
$app->checkPOST($keys);
$userId = $app->escapedPost($keys[0]);
$json = $app->escapedPost($keys[1]);
$sql = "insert into orders(user) value ({$userId})";
$result = $app->query($sql);
$orderId = $conn->insert_id;
if ($orders = json_decode($json, true)) {
    $sql = "";
    foreach ($orders as $order) {
        $sql .= "insert into ordered_items(order_id, item_id, item_count) VALUES ({$orderId},{$order['0']},{$order['1']});";
    }
    $app->multiQuery($sql);
    $resp[error] = 0;
    if (debug) {
        $resp[status] = "success";
    }
} else {
    $resp[error] = 6;
    if (debug) {
        $resp['status'] = "Json decode error";
        $resp['json'] = $json;
        $resp[line] = __LINE__;
    }
}
echo json_encode($resp);