Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- mysqli_connect('localhost', 'root', '', 'info') or die($connect_error);
- ?>
- <?php
- function sanitize($data) {
- mysqli_real_escape_string($connect,$data);
- }
- function protect_page() {
- if (logged_in() === false) {
- header('Location:../../redirect.php');
- }
- }
- function logged_in_redirect() {
- if (logged_in() === true) {
- header('Location: ../../dashboard.php');
- exit();
- }
- }
- ?>
- <?php
- function user_exists($username) {
- $username = sanitize($username);
- $query = mysqli_query($connect,"SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
- mysqli_num_rows($query), 0) == 1) ? true : false;
- }
- function logged_in() {
- return (isset($_SESSION['id'])) ? true : false;
- }
- ?>
- mysqli_connect('localhost', 'root', '', 'info') or die($connect_error);
- ?>
- <?php
- include 'core/init.php';
- if (user_exists('stole') === false) {
- echo 'exists';
- }
- die ();
- if (empty($_POST) === false) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty($username) === true || empty($password) === true) {
- $errors [] = 'Please enter a valid username and password';
- } else if (user_exists($username) === false) {
- $errors [] = 'We can't find that username. Have you registered? ';
- }
- }
- ?>
- <?php
- $connect = mysqli_connect('localhost', 'root', '', 'info') or die($connect_error);
- ?>
- <?php
- function sanitize($data) {
- global $connect;
- mysqli_real_escape_string($connect,$data);
- }
- function protect_page() {
- if (logged_in() === false) {
- header('Location:../../redirect.php');
- }
- }
- function logged_in_redirect() {
- if (logged_in() === true) {
- header('Location: ../../dashboard.php');
- exit();
- }
- }
- ?>
- <?php
- $connect = mysqli_connect('localhost', 'root', '', 'info') or die($connect_error);
- function user_exists($username) {
- global $connect;
- $username = sanitize($username);
- $query = mysqli_query($connect,"SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username'");
- mysqli_num_rows($query), 0) == 1) ? true : false;
- }
- function logged_in() {
- return (isset($_SESSION['id'])) ? true : false;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement