Example #1
0
<?php

//Controller of registration
require_once 'functions/session.php';
require_once 'models/auth.php';
//If user filled the registration form and $_POST not empty
if (!empty($_POST['user_name_reg']) && !empty($_POST['user_password_reg'])) {
    $temp = user_registration($_POST['user_name_reg'], $_POST['user_password_reg']);
    // User Registration data write to db
    if ($temp == true) {
        cok_a_sess($_POST['user_name_reg']);
        header('Location: user.php');
        // directing script to controller for the users user.php
        exit;
        // end of script
    }
}
header('Location: index.php?go=registr');
// if 1)username and password does no exist database
//2) or not entered by user 1. password 2. login 3. password and login together  and pressed submit button
Example #2
0
<?php

require_once 'header.php';
include 'function.php';
include 'db_connect.php';
if (isset($_POST["submit"])) {
    $username = $_POST["user"];
    $password = $_POST["pass"];
    $email = $_POST["email"];
    $sql = "INSERT INTO members (username, email, password) \n\t\tVALUES ('{$username}', '{$email}', '{$password}')";
    if (!mysqli_query($con, $sql)) {
        die('Error: ' . mysqli_error($con));
    } else {
        header("Location: login.php");
    }
    mysqli_close($con);
} else {
    user_registration();
}
require_once 'footer.php';