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