Example #1
0
<?php

require_once "configuration/main.php";
if ($_SESSION['accountid']) {
    //redirect("index");
}
if ($_POST['login']) {
    $mQuery = $mysql->query("SELECT `id` FROM `accounts` WHERE `username` = '" . escape($_POST['username']) . "' AND `password` = '" . password($_POST['password']) . "'");
    if ($mQuery->num_rows) {
        $mData = $mQuery->fetch_assoc();
        $_SESSION['accountid'] = $mData['id'];
        cookie("fm_accountid", $_SESSION['accountid']);
        cookie("fm_username", escape($_POST['username']));
        cookie("fm_password", password($_POST['password']));
        successNotice("You have successfully logged in.");
        redirect("index", 2);
    } else {
        errorNotice("The account information you have entered is invalid.");
    }
}
?>

<style>
	body
	{
		background: url(images/login-background.png) #525252 no-repeat;
		background-size: cover;
	}
</style>

<div align='center'>
Example #2
0
require_once "configuration/main.php";
if ($_SESSION['accountid']) {
    //redirect("index");
}
if ($_POST['signup']) {
    if (strlen($_POST['username']) >= 3) {
        if (strlen($_POST['password']) >= 3) {
            if ($_POST['password'] == $_POST['confirmpassword']) {
                if (strlen($_POST['email']) >= 5 && strpos($_POST['email'], "@") !== false && strpos($_POST['email'], ".") !== false) {
                    $mysql->query("INSERT INTO `accounts` (`username`, `password`, `email`) VALUES ('" . escape($_POST['username']) . "', '" . password($_POST['password']) . "', '" . escape($_POST['email']) . "')");
                    $_SESSION['accountid'] = $mysql->insert_id;
                    cookie("fm_accountid", $_SESSION['accountid']);
                    cookie("fm_username", escape($_POST['username']));
                    cookie("fm_password", password($_POST['password']));
                    successNotice("You have successfully created an account.");
                    redirect("index", 2);
                } else {
                    errorNotice("You have entered an invalid email address.");
                }
            } else {
                errorNotice("Your passwords do not match.");
            }
        } else {
            errorNotice("Your password must be at least 3 characters long.");
        }
    } else {
        errorNotice("Your username must be at least 3 characters long.");
    }
}
?>