Ejemplo n.º 1
0
// check if the script was called after the click of the button of the register form in index.php
if (isset($_POST["register"])) {
    // check if the value are not empty
    if (!empty($_POST["username"]) && !empty($_POST["password"]) && !empty($_POST["repeat_password"]) && !empty($_POST["email"]) && !empty($_POST["role"])) {
        // take out the value from the $_POST array
        $username = $_POST["username"];
        $password = $_POST["password"];
        $repeat_password = $_POST["repeat_password"];
        $role = $_POST["role"];
        $email = $_POST["email"];
        // check if the two password match
        if ($password === $repeat_password) {
            // include a global file with all the classes
            require_once 'Matchup.inc.php';
            // create an object of MUUsers
            $user = new MUUsers();
            // check if the username is already in use
            if (!$user->isUserAlreadyRegistered($username)) {
                // check if the registration was successful
                if ($user->registerUser($username, $password, $email, $role)) {
                    // user is correctly registered
                    $register_response_success = "1";
                    $register_response_message = "Utente%20registrato%20con%20successo";
                } else {
                    // something wrong happen
                    $register_response_success = "0";
                    $register_response_message = "Qualcosa%20di%20inaspettato%20e'%20accaduto";
                }
            } else {
                // user already register
                $register_response_success = "0";
Ejemplo n.º 2
0
            header("location: home.php");
            exit;
            break;
    }
    // take out the updated information from the database
    $newUser = $user->getInformationAboutUser($_SESSION["username"]);
    // reset the session array
    $_SESSION = $newUser;
    // redirect to the home.php and exit the script
    header("location: home.php");
    exit;
} else {
    if (isset($_POST["enable"])) {
        // get out the value from the post array
        $newValue = $_POST["value"];
        $username = $_POST["username"];
        // require the file with all the classes
        require_once 'Matchup.inc.php';
        // create an object of MUUsers
        $user = new MUUsers();
        // update the enable state
        $user->changeEnableState($username, $newValue);
        // redirect the user to the home.php page and exit the script
        header("location: home.php");
        exit;
    } else {
        // redirect user to index.php file
        header("location: index.php");
        exit;
    }
}
Ejemplo n.º 3
0
 *
 * script to login user
 */
// require the session
require_once 'session.php';
// check if the script was called after the button pressed in the login form
if (isset($_POST["login"])) {
    // check if the value are empty
    if (!empty($_POST["username"]) && !empty($_POST["password"])) {
        // extract all the values from $_POST array
        $username = $_POST["username"];
        $password = $_POST["password"];
        // include all the classes
        require_once 'Matchup.inc.php';
        // create an object of MUUsers
        $user = new MUUsers();
        // check if the user is accepted
        if ($user->isUserAccepted($username)) {
            // login the user
            $loggedUser = $user->loginUser($username, $password);
            // check if the user was successfully logged in
            if ($loggedUser) {
                // start session and redirect to home.php
                $_SESSION = $loggedUser;
                header("location: home.php");
                exit;
            } else {
                // something wrong happen
                $login_response_success = "0";
                $login_response_message = "Username%20o%20password%20non%20non%20corrispondono";
            }
Ejemplo n.º 4
0
echo "<td class='td'>Credito</td>";
echo "<td class='td'><input type='text' value='" . $credit . "' disabled/></td>";
echo "<td class='td'><input type='submit' value='Aggiorna' disabled/></td>";
echo "</tr>";
?>
			<tr><form action="update.php" method="POST">
				<td class="td">password</td>
				<td class="td"><input type="hidden" name="key" value="password"/><input autocomplete="off" type="password" name="value" /></td>
				<td class="td"><input name="update" type="submit" value="Aggiorna" /></td>
			</form></tr>
		</table>
		<?php 
// show this part only if the user is an administrator
if ($_SESSION["ruolo"] === "amministratore") {
    // create an object of MUUsers
    $user = new MUUsers();
    // get all the users from the database
    $allUsers = $user->getAllUsers();
    // print some information
    echo "Utenti non ancora accettati";
    echo "<table class='table'>";
    echo "<tr><td class='td'>";
    echo "Email";
    echo "</td><td class='td'>";
    echo "Username";
    echo "</td><td class='td'>";
    echo "Ruolo";
    echo "</td><td class='td'>";
    echo "Accetta/Rifiuta";
    echo "</td></tr>";
    // display all the users