Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Could someone explain to me why my login page is not working?
- I created this account. You can try it at http://k.k8r.us/login.php
- username: k
- password: star
- or you can create your own here: http://k.k8r.us/signup.php
- Here is my login page. It submits to itself, and if there is a successful login it 301 redirects to your "dashy dashboard"
- [php]
- <?php
- require('inc/common.php');
- require('inc/validationKit.php');
- require('inc/dbConnect.php');
- //require('inc/recaptchalib.php');
- $username = $_GET['username'];
- if ( isset($_POST['submitted']) ){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $hashword = md5($password);
- //initialize error tracking
- $errors = 0;
- $errors_username = array();
- $errors_overall = array();
- //check username && combo
- if (strlen($username)>0){
- $result = mysql_query("SELECT * FROM users WHERE ( name='$username' && hashword='$hashword') LIMIT 1");
- $nameExist = mysql_num_rows($result);//die("$username ... $nameExist ... $password");
- if (!$nameExist){
- array_push($errors_overall,"Username or Password is incorrect.");
- }
- }
- else {
- array_push($errors_username,"you must insert a Username or Email to login");
- }
- //----- END check username && combo
- //collect all errors
- $errors = 0;
- $errors += count($errors_username);
- $errors += count($errors_overall);
- //create account
- if (0 == $errors){
- $data = mysql_fetch_row($result);
- $_SESSION['userID'] = $data['ID'];
- $_SESSION['username'] = $data['username'];
- //print_r($data);
- //die();
- //jump to dashboard
- header( 'Location: dashboard.php' );die();
- }
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html>
- <head>
- <title>Login</title>
- <?php include("inc/meta.php");?>
- </head>
- <body>
- <?php include("inc/header.php");?>
- <?php $navLight="logging";include("inc/nav.php");?>
- <?php if (isset($errors) && $errors) echo $errors;?>
- <form action="" method="POST">
- <span class="errors">
- <?php
- if (isset($_GET['m']) && $_GET['m'] == '1') {
- echo "<span class=\"error\">You must be logged in to view that page. God you're stupid</span>";
- }
- ?>
- <?= html_listArray($errors_overall) ?></span>
- <label>
- Username or Email: <input id="username" type="text" name="username" value="<?= $username ?>"/>
- <span class="errors"><?= html_listArray($errors_username) ?></span>
- </label>
- <label>
- Password: <input id="password" type="password" name="password"/>
- </label>
- <input name="submitted" type="hidden" value="1">
- <input type="submit" value="Submit"/>
- </form>
- <?php include("inc/footer.php");?>
- </body>
- </html>
- [/php]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement