I am taking a class on PHP, and we are learning about object classes. I have been told to create an object class called 'LoginBox' that will validate users and redirect them to a new page depending on whether their information was correct or not. My issue is we have yet to study anything like MYSQL, and that is what most people seem to use for these sorts of problems. I have been told that I am able to use a static username and password for this specific problem, since we have yet to study databases.
My code is as follows. Granted, I clearly am not sure how to even approach this problem, and this code is far from finished and probably beyond saving, but this at least can give you an idea of what I have tried. If anyone can point me in the right direction, I would greatly appreciate the help, as I have been trying to figure this out for hours to no success. I apologize in advance for the mess of code that follows.
class LoginBox {
public $userName = "user123";
public $password = "pass123";
public $var1;
public $var2;
public function makeTable() {
echo '<form action="loggedin.php" method="post">
Name: <input type="text" name="username"><br>
E-mail: <input type="text" name="password"><br>
<input type="submit">
</form>';
}
public function __construct() {
$this->var1=isset($_POST['username']) ? $_POST['username'] : null;
$this->var2=isset($_POST['password']) ? $_POST['password'] : null;
}
public function SuccessRedirect() {
if ($var1 = $userName) {
if ($var2 = $password) {
echo "Welcome back!";
}
}
}
public function FailRedirect() {
if ($var <> $userName) {
if ($var2 <> $password) {
}
}
}
}