x
This commit is contained in:
parent
97137da6b9
commit
9a4626e854
@ -19,19 +19,27 @@ class UserController
|
||||
|
||||
public function loginUser()
|
||||
{
|
||||
var_dump($_POST);
|
||||
echo $_POST["username"];
|
||||
$erg = array();
|
||||
$erg = $this->userModel->verifyLogin($_POST["username"], $_POST["password"]);
|
||||
if ($erg["success"] == true) {
|
||||
echo "success";
|
||||
}
|
||||
else {
|
||||
$this->view->setDoMethodName("showUserLoginForm");
|
||||
$this->view->setVars([
|
||||
"errmsg" => $erg["message"]
|
||||
]);
|
||||
$this->showUserLoginForm();
|
||||
}
|
||||
|
||||
|
||||
// on fail
|
||||
$this->view->setDoMethodName("showUserLoginForm");
|
||||
$this->showUserLoginForm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function showUserLoginForm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -2,12 +2,12 @@
|
||||
|
||||
namespace ppa\Model;
|
||||
use ppa\Model\ParticipantModel;
|
||||
use ppb\Library\Msg;
|
||||
//use ppb\Library\Msg;
|
||||
use PDOException;
|
||||
|
||||
class UserModel extends Database
|
||||
{
|
||||
function verifyLogin($pdo, $username, $password)
|
||||
public function verifyLogin($username, $password)
|
||||
{
|
||||
$pdo = $this->linkDB();
|
||||
if (!$pdo) return ['success' => false, 'message' => 'Database connection error.'];
|
||||
@ -20,7 +20,7 @@ class UserModel extends Database
|
||||
$_SESSION['user_id'] = $user['id'];
|
||||
$_SESSION['username'] = $user['username'];
|
||||
$_SESSION['role'] = $user['role']; // Store role
|
||||
return ['success' => true, 'message' => 'Login successful!', 'redirect' => showNotes()];
|
||||
return ['success' => true, 'message' => 'Login successful!', 'redirect' => "xx"];
|
||||
}
|
||||
return ['success' => false, 'message' => 'Invalid username or password.'];
|
||||
} catch (PDOException $e) {
|
||||
|
@ -13,10 +13,15 @@
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
|
||||
<button type="submit" href="?controller=User&do=loginUser">Login</button>
|
||||
<button type="submit">Login</button>
|
||||
<label><?php if (isset($errmsg)):?>
|
||||
<?php echo $errmsg;?>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<p style="margin-top:15px; text-align:center;">Don't have an account? <a href="index.php?page=register">Register here</a></p>
|
||||
</div>
|
||||
<input type="hidden" name="controller" value="User">
|
||||
<input type="hidden" name="do" value="loginUser">
|
||||
</form>
|
||||
</div>
|
||||
<?php include dirname(__DIR__).'/footer.phtml'; ?>
|
Loading…
x
Reference in New Issue
Block a user