public static function map(User $user, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $user->setId($properties['id']);
     }
     if (array_key_exists('first_name', $properties)) {
         $user->setFirstName($properties['first_name']);
     }
     if (array_key_exists('user_password', $properties)) {
         $user->setUserPassword($properties['user_password']);
     }
 }
$userId = $_POST['userId'];
$currentEmail = $_POST['currentEmail'];
$newEmail = $_POST['newEmail'];
$username = $_POST['username'];
$password = $_POST['password'];
//the next step is to check if there exists a user with the passed
//email, username and password. If so update the email variable only.
$user = new User();
if ($user->userExistsWithCredentials($username, $currentEmail, $password)) {
    //now i can update the fetch the object using the id
    $fetchedUser = $user->getUserUsingUserId($userId);
    $modifiedUser = new User();
    $modifiedUser->setUserId($userId);
    $modifiedUser->setUserType($fetchedUser->user_type);
    $modifiedUser->setUsername($fetchedUser->username);
    $modifiedUser->setUserPassword($password);
    $modifiedUser->setUserFullName($fetchedUser->user_full_name);
    $modifiedUser->setUserStatus($fetchedUser->user_status);
    $modifiedUser->setEmail($newEmail);
    $modifiedUser->setUserLastValidLogin($fetchedUser->user_last_valid_login);
    $modifiedUser->setUserFirstInvalidLogin($fetchedUser->user_first_invalid_login);
    $modifiedUser->setUserFailedLoginCount($fetchedUser->user_faild_login_count);
    $modifiedUser->setUserCreateDate($fetchedUser->user_create_date);
    $modifiedUser->setModifiedBy($fetchedUser->modified_by);
    $modifiedUser->setModificationDate($fetchedUser->modification_date);
    $user->update($modifiedUser);
    $data['success'] = true;
    $data['message'] = "<div class='alert alert-success alert-dismissable'>" . "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" . "User email address updated successfully!" . "</div><br/>";
    echo json_encode($data);
} else {
    //echo '.';
Example #3
0
        $this->userImage = $value;
    }
    function getUserImage()
    {
        return $this->userImage;
    }
}
//check if the user exist in DB
$sql = "SELECT * FROM user WHERE login = '******'login']}'" . " AND password = '******'password']}'";
$user_data = mysql_query($sql, $con);
$row = mysql_fetch_array($user_data);
if (empty($row['login'])) {
    //redirect to registration page
    $to = 'not-exist.html';
    header('Location: ' . $to);
    exit;
}
//put user data in Model (User Object)
$user01 = new User();
$user01->setUserLogin($row['login']);
$user01->setUserPassword($row['password']);
$user01->setFullName($row['fullname']);
$user01->setUserType($row['usertype']);
$user01->setUserImage($row['image']);
//put user data in session
$_SESSION['user'] = $user01;
//redirect to the HOME page
$to = 'home.php';
header('Location: ' . $to);
mysql_close($con);
exit;
$userId = $_POST['userId'];
$currentEmail = $_POST['currentEmail'];
$currentUsername = $_POST['currentUsername'];
$currentPassword = $_POST['currentPassword'];
$newPassword = $_POST['newPassword'];
//the next step is to check if there exists a user with the passed
//email, username and password. If so update the email variable only.
$user = new User();
if ($user->userExistsWithCredentials($currentUsername, $currentEmail, $currentPassword)) {
    //now i can update the fetch the object using the id
    $fetchedUser = $user->getUserUsingUserId($userId);
    $modifiedUser = new User();
    $modifiedUser->setUserId($userId);
    $modifiedUser->setUserType($fetchedUser->user_type);
    $modifiedUser->setUsername($fetchedUser->username);
    $modifiedUser->setUserPassword($newPassword);
    $modifiedUser->setUserFullName($fetchedUser->user_full_name);
    $modifiedUser->setUserStatus($fetchedUser->user_status);
    $modifiedUser->setEmail($fetchedUser->email);
    $modifiedUser->setUserLastValidLogin($fetchedUser->user_last_valid_login);
    $modifiedUser->setUserFirstInvalidLogin($fetchedUser->user_first_invalid_login);
    $modifiedUser->setUserFailedLoginCount($fetchedUser->user_faild_login_count);
    $modifiedUser->setUserCreateDate($fetchedUser->user_create_date);
    $modifiedUser->setModifiedBy($fetchedUser->modified_by);
    $modifiedUser->setModificationDate($fetchedUser->modification_date);
    $user->update($modifiedUser);
    $data['success'] = true;
    $data['message'] = "<div class='alert alert-success alert-dismissable'>" . "<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" . "Password updated successfully!" . "</div><br/>";
    echo json_encode($data);
} else {
    //echo '.';
Example #5
0
$database = "3621";
$host_name = "localhost";
if (!empty($_POST['UserName']) && !empty($_POST['UserMail']) && !empty($_POST['UserPassword'])) {
    if ($_POST['UserPassword2'] != $_POST['UserPassword']) {
        include "RegisterPage.php";
        echo '<script language="javascript">';
        echo 'alert("The two passwords do not match with each other!")';
        echo '</script>';
    } else {
        $link = new PDO("mysql:host={$host_name};dbname={$database}", $user_name, $password);
        $statement = $link->prepare("SELECT UserId FROM users WHERE UserName=?");
        $statement->execute(array($_POST['UserName']));
        if ($statement->rowCount() == 0) {
            $user->setUserName($_POST["UserName"]);
            $user->setUserMail($_POST["UserMail"]);
            $user->setUserPassword($_POST["UserPassword"]);
            $user->InsertUser();
            header("Location: RegistrationSuccess.php?success=1");
        } else {
            include "RegisterPage.php";
            echo '<script language="javascript">';
            echo 'alert("Sorry, this username already exists.")';
            echo '</script>';
        }
    }
} else {
    include "RegisterPage.php";
    echo '<script language="javascript">';
    echo 'alert("Please fill in all the fields!")';
    echo '</script>';
}
Example #6
0
<?php

// handle login
//var_dump($_POST);
include_once "classes/user.php";
$user = new User();
$user->setUserName($_POST['username']);
$user->setUserPassword($_POST['password']);
$user->login();