Esempio n. 1
0
 $errorLN = false;
 if (!check_email($email)) {
     $errorE = true;
 }
 if (!check_words($firstName)) {
     $errorFN = true;
 }
 if (!check_words($lastName)) {
     $errorLN = true;
 }
 if (!$errorE && !$errorFN && !$errorLN) {
     db_connect();
     if (db_check_email($email)) {
         message("bad", " User already registred. Try again.<a onclick='history.go(-1);'> Go back. </a>");
     } else {
         db_add_new_user($email, $password, $firstName, $lastName);
         message("good", " Successfully registered! <a href=\"my_page.php\">Continue</a>");
         $_SESSION['loggedin'] = $email;
     }
 } else {
     unset($_SESSION['loggedin']);
     $problemCode = 0;
     if ($errorE) {
         $problemCode += 1;
     }
     if ($errorFN) {
         $problemCode += 2;
     }
     if ($errorLN) {
         $problemCode += 4;
     }
Esempio n. 2
0
<?php

require_once 'libcollection.php';
session_start();
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['passwordConfirm'])) {
    $passConfirm = $_POST['passwordConfirm'];
    $pass = $_POST['password'];
    $usr = $_POST['username'];
    if (validatePass($pass) && validateEmail($usr) && $pass === $passConfirm) {
        /*connect to databasse*/
        db_connect();
        if (is_username_unique($usr)) {
            db_add_new_user($usr, $pass);
            db_close();
            $_SESSION['username'] = $usr;
            header('Location: home.php');
        } else {
            $_SESSION['message'] = '';
            $_SESSION['message'] = $usr . ' already exists';
        }
        db_close();
    }
}
if (!isset($_SESSION['username'])) {
    $_SESSION['user'] = $usr;
    $_SESSION['pass'] = $pass;
    $_SESSION['conf'] = $passConfirm;
    if (!isset($_SESSION['message'])) {
        $_SESSION['message'] = '';
    }
    if (!validatePass($pass)) {
Esempio n. 3
0
<?php

require_once 'libcollection.php';
startSession();
$list_of_users = array(array('username' => '*****@*****.**', 'password' => 'abdcdef'), array('username' => '*****@*****.**', 'password' => '1234567'), array('username' => '*****@*****.**', 'password' => 'abc123'));
$list_of_books = array(array('username' => '*****@*****.**', 'title' => 'My first story', 'story' => '2', 'hero' => 'Jack', 'villain' => 'Giant', 'lair' => 'Castle'), array('username' => '*****@*****.**', 'title' => 'My second story', 'story' => '3', 'hero' => 'Red Riding Hood', 'villain' => 'Witch', 'lair' => 'Gingerbread-house'), array('username' => '*****@*****.**', 'title' => 'The best story', 'story' => '1', 'hero' => 'Jack', 'villain' => 'Wolf', 'lair' => 'Den'));
db_connect();
while (count($list_of_users) != 0) {
    $user = array_pop($list_of_users);
    db_add_new_user($user['username'], $user['password']);
}
while (count($list_of_books) != 0) {
    $book = array_pop($list_of_books);
    db_add_new_book($book['username'], $book['title'], $book['story'], $book['hero'], $book['villain'], $book['lair']);
}
$message .= 'Tables populated successfully';
$_SESSION['message'] = $message;
header('location: adminPage.php');
?>