-
-
Save dennisdegryse/c3eeab6d9819a788125a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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