Permalink
Browse files

More work on the user management bits.

  • Loading branch information...
1 parent a2fa0b4 commit 1cd9aec66a877ee6c35f4db5ff5389d6e651d6bc @emasters committed May 20, 2012
Showing with 164 additions and 46 deletions.
  1. +3 −1 index.php
  2. +48 −30 login.php
  3. +113 −15 register.php
View
@@ -54,8 +54,10 @@
<?php
if (empty($logged_in)) {
echo "<li><a href=\"login.php\">Login</a></li>";
+ echo "<li><a href=\"register.php\">Register</a></li>";
} else {
echo "<li><a href=\"#profile\">".$_SESSION['email']."</a></li>";
+ echo "<li><a href=\"logout.php\">Logout</a></li>";
}
?>
@@ -91,7 +93,7 @@
<div class="span4">
<h2>Bookmarklet</h2>
<p>Drag the button below to your bookmark bar.</p>
- <p><a href="javascript:(function(){document.location='http://b.elide.us/shorten.php?longurl='+encodeURIComponent(location.href)}());" class="btn">Shorten It</a></p>
+ <p><a href="javascript:(function(){document.location='<?php echo BASE_HREF; ?>shorten.php?longurl='+encodeURIComponent(location.href)}());" class="btn">Shorten It</a></p>
</div>
<div class="span4">
<h2>API Key</h2>
View
@@ -1,35 +1,43 @@
<?php
+error_reporting(E_ALL);
+ini_set('display_errors', '1');
+
require_once 'classes/Auth.class.php';
session_start();
$auth = new Auth();
-if (isset($_POST['username']) && isset($_POST['password'])) {
- $status = $auth->login($_POST['username'], $_POST['password']);
-
+if (isset($_POST['email']) && isset($_POST['password'])) {
+ $status = $auth->login($_POST['email'], $_POST['password']);
+ //echo $status;
if ($status == 0) {
header('Location: index.php');
}
else {
switch ($status) {
case 1:
$error = 'User not verified, please check your email for verification';
- break;
+ //break;
case 2:
$error = 'User is not active, please check your email for activation information';
- break;
+ //break;
case 3:
$error = 'Username and password correct, but issue logging in, try again.';
- break;
+ //break;
case 4:
$error = 'Error logging in, please check username and/or password and try again';
- break;
- }
+ //break;
+ }?>
+ <div class="alert alert-error">
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ <h4 class="alert-heading">Login Error!</h4>
+ <?php echo $error; ?>
+ </div>
+ <?php
}
}
-else {
- ?>
+?>
<!DOCTYPE html>
<html lang="en">
<head>
@@ -76,7 +84,7 @@
}
</style>
-
+ <script type="text/javascript" src="./js/jquery-1.7.2.min.js"></script>
</head>
<body>
<div class="navbar navbar-fixed-top">
@@ -88,13 +96,14 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="#">Shorten It</a>
+ <a class="brand" href="index.php">Shorten It</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="#">Home</a></li>
- <li><a href="#about">About</a></li>
- <li><a href="#contact">Contact</a></li>
+ <li><a href="index.php">Home</a></li>
+ <li><a href="index.php#about">About</a></li>
+ <li><a href="index.php#contact">Contact</a></li>
<li class="active"><a href="#login">Login</a></li>
+ <li><a href="register.php">Register</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -103,20 +112,18 @@
</div>
<div class="container">
<div class="content">
- <div class="row">
+ <?php if (isset($_GET['verified'])) {
+ echo 'Your account is verified, please login below <br />';
+ }
+ ?>
+ <div class="row">
<div class="login-form">
<h2>Login</h2>
<form method="post" action="login.php" name="loginForm">
- <?php if (isset($error)) {
- echo 'There was an issue logging in. Error: ' . $error . '<br />';
- }
- else if (isset($_GET['verified'])) {
- echo 'Your account is verified, please login below <br />';
- }
- ?>
+
<fieldset>
<div class="clearfix">
- <input type="text" placeholder="Username" name="username">
+ <input type="text" placeholder="Email" name="email">
</div>
<div class="clearfix">
<input type="password" placeholder="Password" name="password">
@@ -125,13 +132,24 @@
</fieldset>
<a href="forgot_password.php">Forgot Password</a>
</form>
- </div>
+ </div>
</div>
</div>
</div> <!-- /container -->
-</form>
+ <script type="text/javascript">
+ $(".alert").alert('close')
+ </script>
+ <script src="./js/bootstrap/bootstrap-transition.js"></script>
+ <script src="./js/bootstrap/bootstrap-alert.js"></script>
+ <script src="./js/bootstrap/bootstrap-modal.js"></script>
+ <script src="./js/bootstrap/bootstrap-dropdown.js"></script>
+ <script src="./js/bootstrap/bootstrap-scrollspy.js"></script>
+ <script src="./js/bootstrap/bootstrap-tab.js"></script>
+ <script src="./js/bootstrap/bootstrap-tooltip.js"></script>
+ <script src="./js/bootstrap/bootstrap-popover.js"></script>
+ <script src="./js/bootstrap/bootstrap-button.js"></script>
+ <script src="./js/bootstrap/bootstrap-collapse.js"></script>
+ <script src="./js/bootstrap/bootstrap-carousel.js"></script>
+ <script src="./js/bootstrap/bootstrap-typeahead.js"></script>
</body>
-</html>
- <?php
-}
-?>
+</html>
View
@@ -8,27 +8,125 @@
$auth = new Auth();
-if (isset($_POST['email']) && isset($_POST['pw1'])) {
- if ($auth->createUser($_POST['email'], $_POST['pw1'])) {
- echo 'Account Created, please check your email for verification information';
- }
+if (isset($_POST['email']) && isset($_POST['password'])) {
+ if ($auth->createUser($_POST['email'], $_POST['password'])) { ?>
+ <div class="alert alert-success">
+ <a class="close" data-dismiss="alert" href="#">×</a>
+ <h4 class="alert-heading">You're Registered!</h4>
+ Account Created, please check your email for verification information
+ </div>
+ <?php }
}
?>
-<html>
-<head>
-<title>
-Register for site
-</title>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Shorten It - Register</title>
+ <meta name="description" content="">
+ <meta name="author" content="">
+
+ <!-- Le styles -->
+ <link href="./css/bootstrap.css" rel="stylesheet">
+ <style type="text/css">
+ /* Override some defaults */
+ html, body {
+ background-color: #eee;
+ }
+ body {
+ padding-top: 40px;
+ }
+ .container {
+ width: 300px;
+ }
+
+ /* The white background content wrapper */
+ .container > .content {
+ background-color: #fff;
+ padding: 20px;
+ margin: 0 -20px;
+ -webkit-border-radius: 10px 10px 10px 10px;
+ -moz-border-radius: 10px 10px 10px 10px;
+ border-radius: 10px 10px 10px 10px;
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ box-shadow: 0 1px 2px rgba(0,0,0,.15);
+ }
+
+ .register-form {
+ margin-left: 65px;
+ }
+
+ legend {
+ margin-right: -50px;
+ font-weight: bold;
+ color: #404040;
+ }
+
+ </style>
+ <script type="text/javascript" src="./js/jquery-1.7.2.min.js"></script>
</head>
-
<body>
-<form name="register" action="register.php" method="post">
-Email: <input type="text" name="email" />
-<br />Password: <input type="password" name="pw1" />
-<br /><input type="Submit" value="Submit" />
-</form>
+ <div class="navbar navbar-fixed-top">
+ <div class="navbar-inner">
+ <div class="container">
+
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </a>
+ <a class="brand" href="index.php">Shorten It</a>
+ <div class="nav-collapse">
+ <ul class="nav">
+ <li><a href="index.php">Home</a></li>
+ <li><a href="index.php#about">About</a></li>
+ <li><a href="index.php#contact">Contact</a></li>
+ <li ><a href="login.php">Login</a></li>
+ <li class="active"><a href="register.php">Register</a></li>
+
+ </ul>
+ </div><!--/.nav-collapse -->
+ </div>
+ </div>
+ </div>
+ <div class="container">
+ <div class="content">
+ <div class="row">
+ <div class="register-form">
+ <h2>Register</h2>
+ <form name="registerForm" action="register.php" method="post">
+ <fieldset>
+ <div class="clearfix">
+ <input type="text" placeholder="Email" name="email">
+ </div>
+ <div class="clearfix">
+ <input type="password" placeholder="Password" name="password">
+ </div>
+ <button class="btn btn-primary" type="submit">Register</button>
+ </fieldset>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div> <!-- /container -->
+ <script type="text/javascript">
+ $(".alert").alert('close')
+ </script>
+ <script src="./js/bootstrap/bootstrap-transition.js"></script>
+ <script src="./js/bootstrap/bootstrap-alert.js"></script>
+ <script src="./js/bootstrap/bootstrap-modal.js"></script>
+ <script src="./js/bootstrap/bootstrap-dropdown.js"></script>
+ <script src="./js/bootstrap/bootstrap-scrollspy.js"></script>
+ <script src="./js/bootstrap/bootstrap-tab.js"></script>
+ <script src="./js/bootstrap/bootstrap-tooltip.js"></script>
+ <script src="./js/bootstrap/bootstrap-popover.js"></script>
+ <script src="./js/bootstrap/bootstrap-button.js"></script>
+ <script src="./js/bootstrap/bootstrap-collapse.js"></script>
+ <script src="./js/bootstrap/bootstrap-carousel.js"></script>
+ <script src="./js/bootstrap/bootstrap-typeahead.js"></script>
</body>
</html>

0 comments on commit 1cd9aec

Please sign in to comment.