Exemple #1
0
function checkIfUserRegistered($uname)
{
    if (DBHandler::checkIfUserRegistered($uname)) {
        $_SESSION['registered'] = 1;
        redirectUser('entries.php');
    } else {
        showRegistrationForm();
    }
}
Exemple #2
0
{
    if ($_SERVER['REQUEST_METHOD'] != 'POST') {
        return false;
    }
    if (!validateRegistration()) {
        return false;
    }
    $query = composeQuery();
    $connection = connect();
    $result = mysql_query($query, $connection);
    if (!$result) {
        echo "<p class='center'>Registration is failed. Please try again.</p>";
        mysql_close($connection);
        return false;
    }
    $customer_id = mysql_insert_id($connection);
    echo "\n      <p class='center'>\n      Congratulations! You have been registered successfully.\n      </p>";
    showCustomer($connection, $customer_id);
    echo "<h3>Go to <a href='/'>Login Page</a></h3>";
    mysql_close($connection);
    return true;
}
function showRegistrationForm()
{
    echo "\n      <form action='{$_SERVER['PHP_SELF']}' method='post'>\n      <fieldset>\n      <legend>Enter your registration information below</legend>\n      <p class='form'>\n      <label>Username: </label>\n      <input type='text' name='username' value='{$_POST['username']}'>\n      </p>\n      <p class='form'>\n      <label>Password: </label>\n      <input type='password' name='password' value=''>\n      </p>\n      <p class='form'>\n      <label>Retype Password: </label>\n      <input type='password' name='password2' value=''>\n      </p>\n      <p class='form'>\n      <label>First Name: </label>\n      <input type='text' name='first_name' value='{$_POST['first_name']}'>\n      </p>\n      <p class='form'>\n      <label>Last Name: </label>\n      <input type='text' name='last_name' value='{$_POST['last_name']}'>\n      </p>\n      <p class='form'>\n      <label>Email: </label>\n      <input type='text' name='email' value='{$_POST['email']}'>\n      </p>\n      </fieldset>\n      <br>\n      <input type='submit' class='button' name='submit' value='Register'>\n      </form>";
}
showHeader('New Customer Registraion');
if (!register()) {
    showRegistrationForm();
}
showFooter();