[insert_php]
/*
Copyright Kempen Automatisering 2016 – All Rights Reserved
www.kempenautomatisering.nl
*/

error_reporting(E_ERROR | E_PARSE);
session_start();

if (!empty($_SESSION[‘user_id’])) {
$_SESSION[‘user_id’] = null;
$_SESSION[‘company_id’] = null;
$_SESSION[‘username’] = null;
}

if (!file_exists(‘config.php’)) {
exit;
}
include (‘config.php’);

if (isset($_POST[‘login_handler’])) {
$username = $_POST[‘username’];
$password = $_POST[‘password’];

$_SESSION[‘username’] = $username;
if (empty($username) or empty($password)) {
$message = ‘Email and password are required.’;
}
else if (substr_count($username, ‘*’) > 0 or substr_count($password, ‘*’) > 0) {
$message = ‘Email or password is incorrect.’;
}
else {
$request = $fm->newFindCommand(‘cwp_contacts’);
$request->addFindCriterion(’emailWork’, ‘==’ . $username);
$request->addFindCriterion(‘password’, ‘==’ . $password);
$result = $request->execute();
if (FileMaker::isError($result)) {
if ($result->code == 401) {
$message = ‘Email or password is not recognised.’;
}
else {
$message = ‘Error: ‘ . $result->message;
}
}
else {
$records = $result->getRecords();
$record = $records[0];
$_SESSION[‘user_id’] = $record->getField(‘ID’);
$_SESSION[‘company_id’] = $record->getField(‘IDcompanies’);
$_SESSION[‘company_name’] = $record->getField(‘companyName’);
}
}
}

if (!empty($_SESSION[‘user_id’])) {
header(‘Location: list.php’);
exit;
}
[/insert_php]

Email


[insert_php]
if(!empty($message)) {
echo $message;
}
[/insert_php]