Exemplo n.º 1
0
 public function logout()
 {
     // unset sessions
     // Set logout success message
     $_SESSION = array();
     session_destroy();
     // return to login page
     echo 'You have been logged out';
     header('Location: ' . global_url());
 }
Exemplo n.º 2
0
 public function delete($user_id)
 {
     // Delete a user
     if ($user_id != NULL) {
         if ($this->crud_users->delete($user_id)) {
             header('Location: ' . global_url() . 'users');
             die;
         }
     } else {
         echo "Invalid id";
         $this->index();
     }
 }
Exemplo n.º 3
0
        <label for="username">Username</label>
        <input name="username" type="text" <?php 
echo isset($single_user['username']) ? 'value="' . $single_user['username'] . '"' : NULL;
?>
      </p>
      <?php 
if (!isset($single_user['id'])) {
    ?>
      <p>
        <label for="password">Password</label>
        <input name="password" type="password">
      </p>
      <?php 
}
?>
      <p>
        <?php 
echo isset($single_user['id']) ? '<input type="hidden" name="id" value="' . $single_user['id'] . '">' : NULL;
?>
        <input type="submit">
      </p>
    </form>

    <p><a href="<?php 
echo global_url('users');
?>
">Back to main list</a></p>

  </body>
</html>
Exemplo n.º 4
0
        <td><?php 
        echo $user['lastname'];
        ?>
</td>
        <td><?php 
        echo $user['username'];
        ?>
</td>
        <td><a href="<?php 
        echo global_url('users/edit/' . $user['id']);
        ?>
">Edit user</a></td>
        <td><a href="<?php 
        echo global_url('users/delete/' . $user['id']);
        ?>
">Delete user</a></td>
      </tr>
    <?php 
    }
    ?>
    <?php 
}
?>
    </table>
    <p><a href="<?php 
echo global_url('login/logout');
?>
">Logout</a></p>
  </body>
</html>
Exemplo n.º 5
0
    <form action="<?php 
echo global_url('register/save');
?>
" method="post">
      <p>
        <label for="firstname">First name</label>
        <input name="firstname" type="text">
      </p>
      <p>
        <label for="lastname">Last name</label>
        <input name="lastname" type="text">
      </p>
      <p>
        <label for="username">Username</label>
        <input name="username" type="text">
      </p>
      <p>
        <label for="password">Password</label>
        <input name="password" type="password">
      </p>
      <input type="submit">
    </form>

    <p><a href="<?php 
echo global_url('login/');
?>
">Back to login</a></p>

  </body>
</html>
Exemplo n.º 6
0
<html>
  <head>
    <meta charset="utf-8">
    <title>Login Page</title>
  </head>
  <body>
    <h1>Login Page</h1>

    <form action="<?php 
echo global_url('login/authenticate');
?>
" method="post">
      <p>
        <label for="username">Username</label>
        <input name="username" type="text">
      </p>
      <p>
        <label for="password">Password</label>
        <input name="password" type="password">
      </p>
      <input type="submit">
    </form>

    <a href="<?php 
echo global_url('register');
?>
">register account</a>

  </body>
</html>
Exemplo n.º 7
0
define('ROOT', dirname(dirname(__FILE__)));
// 5. Define a basic user table for a mysql database and write a simple CRUD to manage the data
// including a login function.
// Get the url
function global_url($path = NULL)
{
    $base_url = 'http://php-lamp-104185.nitrousapp.com:3000/justit-php-test/index.php/';
    return $path == NULL ? $base_url : $base_url . $path;
}
if ($_SERVER['PATH_INFO'] != "") {
    $url = explode("/", $_SERVER['PATH_INFO']);
    $classname = $url[1] != "" ? $url[1] : 'login';
    $method = $url[2] != "" ? $url[2] : 'index';
    // Here we shall load up each class based the url parameters
    if (file_exists('controllers/' . $classname . '.php')) {
        include 'controllers/' . $classname . '.php';
        $object = new $classname();
        if (method_exists($object, $method)) {
            if (isset($url[3])) {
                $object->{$method}($url[3]);
            } else {
                $object->{$method}();
            }
        } else {
            echo "Method does not exist";
        }
    }
} else {
    header('Location: ' . global_url());
    die;
}
Exemplo n.º 8
0
  </head>
  <body>
    <h1>Edit the details for: </h1>

    <form action="<?php 
echo global_url('user/save');
?>
" method="post">
      <p>
        <label for="firstname">First name</label>
        <input name="firstname" type="text">
      </p>
      <p>
        <label for="lastname">Last name</label>
        <input name="lastname" type="text">
      </p>
      <p>
        <label for="username">Username</label>
        <input name="username" type="text">
      </p>
      <input type="submit">
    </form>

    <p><a href="<?php 
echo global_url('login/register_form');
?>
">View all users</a></p>

  </body>
</html>