Jump to content

liboration77

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

liboration77's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am making a login script that locks a user account for 15 minutes if someone fails to login correctly after 5 attempts. It works, however, I do not know how to unlock it 15 minutes later. My original thought would be to store in the database the time at which the account was locked. Then everytime someone tried to log into the locked account it would check to see if the current time is 15 minutes or more past the time at which the account was locked. My problem is I have no idea on how to successfully compare two times like this. Any ideas?
  2. Hi, I am trying to create a login system using a mysql clas that I created mysefl. However, I get this error: [quote][b]Fatal error:[/b] Call to a member function on a non-object[/quote] [b]Here is the beginning of the login script: (login.php)[/b] [code]<?php $root = './'; $fileRoot = '../'; DEFINE('IN_TCMS','True'); require_once($fileRoot.'sources/classes/class_mysql.php'); $db = New mysql(); function main() { session_start(); if(!isset($_SESSION['username'], $_SESSION['password'])) { header("location: login.php?act=01"); } else { header("location: index.php"); } } $choice = $_GET['act']; switch($choice) { case "01": do_login(); break; case "02": do_logout(); break; default: main(); } function do_login(){ if (!isset($_POST['valid'])) { include($root.'login.html'); } else { $username = $_POST['user']; $pass = $_POST['pass']; $password = SHA1($pass); $safeuser = preg_replace("/[^a-z\d]/i",'',$username); $db->fetchrow("select * from `users` where `username` = '$safeuser' and `password`='$password'"); $auth = false; if($row['username'] == $safeuser){ $auth = true; session_start(); $_SESSION['username'] = $safeuser; $_SESSION['password'] = $password; } } if($auth){ session_start(); echo('Logged in!'); } else{ } } [/code] [b]Here is the mysql class: (class_mysql.php)[/b] [code]<?php $root = '../'; if(!defined("IN_TCMS")) { die("Direct access to this file has been denied."); } class mysql { function query($query) { require_( $root . 'config.php' ); $connection = mysql_connect($INFO['dbhost'], $INFO['dbuser'], $INFO['dbpass']); $select = $mysql_select_db($INFO['dbhost'], $connection); //Run the query $state = mysql_query($query); if(!$state) { return false; } mysql_close($connection); } function fetchrow($query) { require_( $root . 'config.php' ); $connection = mysql_connect($INFO['dbhost'], $INFO['dbuser'], $INFO['dbpass']); $select = $mysql_select_db($INFO['dbhost'], $connection); $result = mysql_query($query); $row = mysql_fetch_row($result); if(!$result) { return false; } mysql_close($connection); } } ?>[/code] The error refers to the login.php file at this line: [quote] $db->fetchrow("select * from `users` where `username` = '$safeuser' and `password`='$password'");[/quote] Can anyone offer some help on why this is occuring?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.