<?php 
session_start();
require 'DBConnection.php';
date_default_timezone_set('Asia/Dhaka');
if (isset($_POST["login"])) {
    //echo "I am in login";
    $password = selectPassword($_POST["email"]);
    if ($password) {
        if ($password == $_POST["password"]) {
            $_SESSION["currentUser"] = $_POST["email"];
            echo "successful";
        } else {
            echo "Wrong Password";
        }
    } else {
        echo "Wrong User Name";
    }
}
if (isset($_POST["signup"])) {
    $inputEmail = $_POST["inputEmail"];
    $name = $_POST["name"];
    $inputPassword = $_POST["inputPassword"];
    $retypePassword = $_POST["retypePassword"];
    $institutionName = $_POST["institutionName"];
    $photo = "";
    if (selectUserInfo($inputEmail) != null) {
        echo "This email already used for another account !";
    } else {
        insertUserInfo($inputEmail, $inputPassword, $name, $institutionName, $photo);
        $_SESSION["currentUser"] = $_POST["inputEmail"];
Ejemplo n.º 2
0
{
    global $test;
    $user = filter_input(INPUT_POST, "username", FILTER_SANITIZE_STRING);
    $password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
    $query = "SELECT user_name FROM user_name\n\t\t\tWHERE user_name='{$user}'\n\t\t\tAND password=AES_ENCRYPT('{$password}', 'test')";
    $statement = $test->prepare($query);
    $statement->execute();
    if ($statement->rowCount()) {
        return TRUE;
        echo "password is correct";
    } else {
        return FALSE;
        echo "password is incorrect";
    }
}
$password = selectPassword();
if ($user_name == TRUE) {
    echo "user exists";
    if ($password == TRUE) {
        $user = filter_input(INPUT_POST, "username", FILTER_SANITIZE_STRING);
        $_SESSION['user'] = $user;
        $location = "Location: whybuy.php";
        $_SESSION['loginsuccess'] = "Welcome {$user}!";
        //$_SESSION['password']=$password;
        //$_SESSION['user_level']=$user_level;
        echo "password is correct";
    } else {
        $_SESSION["login_msg"] = "invalid password";
        $location = "Location: login.php";
        echo "password is invalid";
    }