<?php //this file is used for signing up or logging in/out users. include_once "./system/db_functions.php"; include_once './system/db_connect.php'; include_once './system/GCM.php'; $db = new DB_Functions(); if (isset($_POST['username'])) { $user = $db->sanitize($_POST['username']); if (isset($_POST['password'])) { $pass = $db->sanitize($_POST['password']); if (isset($_POST['email'])) { $email = $db->sanitize($_POST['email']); if (isset($_GET['login'])) { $db->login($user, $pass, $email); } if (isset($_GET['signup'])) { $db->signup($user, $pass, $email); } } } else { if (isset($_POST['hash'])) { $hash = $_POST['hash']; if (isset($_GET['logout'])) { $db->logout($user, $hash); } } } }
<?php session_start(); if (isset($_POST['login']) && isset($_POST['password'])) { include_once './db_functions.php'; $db = new DB_Functions(); $result = $db->login($_POST['login'], $_POST['password']); include './sharedkeys.php'; if ($result == null) { $_SESSION['respons'] = "Wrong username or password!!"; header("Location:" . PROJECT_URL . "login.php"); die; } /* $row = mysql_fetch_array($result); $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; $_SESSION['status'] = $row['status']; $_SESSION['startup'] = $row['startup']; $loc = $row['startup'];*/ $_SESSION['fname'] = "AppUser"; $_SESSION['lname'] = "Anonymus"; $_SESSION['status'] = "ADMIN"; $_SESSION['startup'] = "index.php"; $loc = PROJECT_URL . "index.php"; header("Location:" . $loc); }
<?php //session_save_path(""); session_start(); include './sharedkeys.php'; if (isset($_SESSION['startup'])) { header("Location: " . PROJECT_URL . $_SESSION['startup']); } if (isset($_POST['username']) && isset($_POST['password'])) { include_once './db_functions.php'; $db = new DB_Functions(); $result = $db->login($_POST['username'], $_POST['password']); if ($result == null) { header("Location:" . PROJECT_URL . "login.php"); } $user_page = "login.php"; while ($row = mysql_fetch_array($result)) { $_SESSION['fname'] = $row['fname']; $_SESSION['lname'] = $row['lname']; $_SESSION['status'] = $row['status']; $_SESSION['startup'] = $row['startup']; $user_page = $row['startup']; } header("Location:" . PROJECT_URL . $user_page); } else { header("Location:" . PROJECT_URL . "login.php"); }
<?php if (isset($_POST['tag']) && $_POST['tag'] != '') { $tag = $_POST['tag']; require_once "db_functions.php"; $db = new DB_Functions(); $response = array(); if ($tag == 'login') { $user_email = $_POST['user_email']; $user_password = $_POST['user_password']; $user = $db->login($user_email, $user_password); if ($user) { $response["success"] = "1"; $response["user_id"] = $user["id"]; $response["user_email"] = $user["user_email"]; $response["user_password"] = $user["user_password"]; $response["user_name"] = $user["user_name"]; echo json_encode($response); error_log("Index Login Json >>" . json_encode($response) . "\r\n", 3, "Log.log"); } else { $response["error"] = "1"; $response["error_message"] = "ایمیل یا گذرواژه نادرست است."; echo json_encode($response); } } else { if ($tag == 'register') { $user_email = $_POST['user_email']; $user_password = $_POST['user_password']; $user_name = $_POST['user_name']; if ($db->isUserExisted($user_email)) { $response["error"] = "2"; $response["error_message"] = "این ایمیل قبلا ثبت شده است";