Skip to content

Instantly share code, notes, and snippets.

@dennisdegryse
Forked from anonymous/gist:869feb24ffb714dbebf0
Last active August 29, 2015 14:13
Show Gist options
  • Save dennisdegryse/c3eeab6d9819a788125a to your computer and use it in GitHub Desktop.
Save dennisdegryse/c3eeab6d9819a788125a to your computer and use it in GitHub Desktop.
<?php
error_reporting(E_ALL);
use databasephp\DatabaseConnection as datab;
use logincrudphp\login as logi;
require_once('src/databasephp/DatabaseConnection.php');
require_once('src/logincrudphp/login.php');
session_start();
$valid_entities = [
'user' => [ 'prefix' => 'u', 'redirect' => 'user/u_home.php' ] ,
'store' => [ 'prefix' => 's', 'redirect' => 'store_owner/so_home.php' ],
'interior' => [ 'prefix' => 'i', 'redirect' => 'interior_designer/id_home.php' ],
'admin' => [ 'prefix' => 'a', 'redirect' => 'admin/a_home.php' ] ];
# don't let the creative minds find a way to h4xle your DB
if (!in_array($_GET['name'], $valid_entities)) {
echo "<script>alert('Invalid entity');</script>";
exit();
} else {
$action = (object) $valid_entities[$_GET['name']];
/* DEBUG */ echo "<pre>Current Entity: <b>{$_GET['name']}</b>\n";
/* DEBUG */ var_dump($action); echo "\n";
}
$dataobj = new datab();
$handle = $dataobj->gethandle();
$logobj = new logi($handle);
$tname = 'teeyli_' . $_GET['name'] . '_details';
if (isset($_POST['submit'])) {
/* DEBUG */ echo "processing submit: ";
if ($logobj->verify_credentials($_POST['login_id'], $_POST['login_password'], $tname)) {
/* DEBUG */ echo "SUCCESS!\n";
$_SESSION[$action->prefix . '_login_id'] = $_POST['login_id'];
header("Location:" . $action->redirect);
} else {
/* DEBUG */ echo "FAILURE!\n";
echo "<script>alert('Invalid Login');</script>";
}
//unset($_POST['submit']);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment