Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( isset($_POST["submit"]) )
- {
- echo "calling before sessions_set_cookie_params" ;
- if ( $_POST["remember"] == "on") // this isn't working for some reason
- {
- // extend expiration date of cookie
- session_set_cookie_params('3600');
- session_set_cookie_params(3600);
- echo "<br/>calling after sessions_set_cookie_params" ;
- }
- }
- require_once("includes/session.php"); //session start ?>
- <?php require_once("includes/connection.php"); ?>
- <?php require_once("includes/functions.php"); ?>
- <?php require_once("includes/header.php"); ?>
- <?php
- if ( isset($_GET["logout"]) )
- {
- if ( $_GET["logout"] == 1 ) $message = "Successfully logged out" ;
- }
- if (logged_in())
- {
- // redirect_to("index.php?loggedin=1") ;
- }
- if ( isset($_POST["submit"]) )
- {
- $errors = array() ;
- // echo "this shouldn't be here" ;
- // validating if username is empty. do the same for password.
- if ( !isset($_POST["email"]))
- {
- $errors[] = $_POST["email"] ;
- }
- if ( !isset($_POST["password"]))
- {
- $errors[] = $_POST["password"] ;
- }
- //if after validating everything is all right.
- if (empty($errors))
- {
- $email = $_POST["email"] ;
- $hashed_password = sha1($_POST["password"] ) ;
- $query = " SELECT * FROM users
- WHERE email = '{$email}'
- AND hashed_password = '{$hashed_password}'
- " ;
- $result_set = mysql_query($query, $connection) ;
- confirm_query($result_set) ;
- // Various methods to check if the query went smoothly.
- if(mysql_num_rows($result_set) == 1 ) //first method
- {
- $message = " - success! " ;
- $found_user = mysql_fetch_array($result_set) ;
- // $_COOKIE["user_id"] = $found_user["id"] ; doesn't works don't know why.
- // setcookie("user_id", $found_user["id"]) ; // works !!
- $_SESSION['user_id'] = $found_user["id"] ;
- $_SESSION['email'] = $found_user["email"] ;
- $_SESSION['colony_id'] = $found_user["colony_id"] ;
- // this needs to be on top of the page.
- /* if ( $_POST["remember"] == "on")
- {
- $message .= " - remember me - " ;
- // extend expiration date of cookie
- session_set_cookie_params('3600');
- } */
- // redirect_to("index.php") ;
- }
- else
- {
- $message = " - no success. Problem? " . mysql_error() ;
- }
- }
- else
- {
- $message .= " - You forgot to enter your username/password" ;
- }
- }
- ?>
- <div id="content-wrap">
- <div id="main">
- <a name="TemplateInfo" id="TemplateInfo"></a>
- <?php if ( isset($message) ) echo "<h2>{$message}</h2>" ?>
- <h1>Login <span class="green">to delhibuy.in</span></h1>
- <hr/>
- <?php if (isset($message)) { echo $message ; } ?>
- <p><strong>Log in </strong> to access your account settings.</p>
- <form action="login.php" method="post" >
- <p>
- <label>Email</label>
- <input type="text" name="email" />
- <label>Password</label>
- <input type="password" name="password" />
- <br/>
- <input type="checkbox" name="remember" id="remember" value="on" /> Save Password <br/>
- <input class="button" type="submit" name="submit" value="Submit" />
- </p>
- </form>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement