Jump to content

classifieds100

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

classifieds100's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I need a little help to create a PHP login script that check for 3 values in a database and allow someone to login if all 3 values are true. I'm a beginer so please any help is appreciated. I have this code here and the tables of my database that has the information that I need the login script to check. The 3 values I want the script to check are username, password, software status. If username and password are correct but the software status is "OFF" then the user should NOT be able to login. Software status must be "ON" and username and password correct to allow user to login. The username is the "email" of the user, the password is the "custkey" and the ON/OFF status is the "software_status". TABLE `customers` (   `customerid` int(7) NOT NULL auto_increment,   `software_name` varchar(65) NOT NULL default '',   `date` date NOT NULL default '0000-00-00',   `name` varchar(65) NOT NULL default '',   `city` varchar(50) NOT NULL default '',   `country` varchar(60) NOT NULL default '',   `email` varchar(120) NOT NULL default '',   `custkey` varchar(32) NOT NULL default '',   `note` varchar(200) NOT NULL default '',   `times_accessed` int(7) NOT NULL default '0',   `check_frequency` int(7) NOT NULL default '24',   `last_accessed` date NOT NULL default '0000-00-00',   `expiry_date` date NOT NULL default '0000-00-00',   `software_status` char(3) NOT NULL default 'ON',   `urls_allowed` int(7) NOT NULL default '4',   PRIMARY KEY  (`customerid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=122 ; <?php // Connects to your Database mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("Database_Name") or die(mysql_error()); //Checks if there is a login cookie if(isset($_COOKIE['ID_my_site'])) //if there is, it logs you in and directes you to the members page { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM customers WHERE username = '$email'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['custkey']) { } else { header("Location: customers.php"); } } } //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die('You did not fill in a required field.'); } // checks it against the database if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $check = mysql_query("SELECT * FROM customers WHERE email = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die('User does not exist in our database.'); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = stripslashes($_POST['pass']); $info['password'] = stripslashes($info['password']); $_POST['pass'] = ($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die('Incorrect password, please try again.'); } else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(ID_my_site, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour); //then redirect them to the members area header("Location: customers.php"); } } } else { // if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <table border="0"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td><td> <input type="text" name="username" maxlength="40"> </td></tr> <tr><td>Password:</td><td> <input type="password" name="pass" maxlength="50"> </td></tr> <tr><td colspan="2" align="right"> <input type="submit" name="submit" value="Login"> </td></tr> </table> </form> <?php } ?> I don't know if I get the code correct so far. But what I mostly need is a piece of code that check the status ON or OFF to let someone in or not. Thanks in Advance.
  2. Hi, I have a script in which I need to get these two values automatically: # full root path to directory (ie: /www/data/docs/user.com/public) $this->directory_root = "."; # http path to directory (ie: [a href=\"http://user.com/public)\" target=\"_blank\"]http://user.com/public)[/a] (no trailing slash) # Note: this must be a directory path you cannot use [a href=\"http://user.com/public/sitemap.php\" target=\"_blank\"]http://user.com/public/sitemap.php[/a] $this->homepage = "."; I have try to replace the first $this->directory_root = "."; with: $this->directory_root = "$_SERVER['DOCUMENT_ROOT'] . dirname(__FILE__)"; But I'm sure I get it wrong somehow. And the second part I also can't get it to work either. See more here: ############################## CONFIGURATIONS ################################# # html page on/off toggle writing of html header and footer $this->html = "on"; # width of <table> $this->table_width = "100%"; # on/off $this->debug = "off"; /* turn off/on display of working path. not recommened to leave on during public use. */ # full root path to directory (ie: /www/data/docs/user.com/public) $this->directory_root = "."; # http path to directory (ie: [a href=\"http://user.com/public)\" target=\"_blank\"]http://user.com/public)[/a] (no trailing slash) # Note: this must be a directory path you cannot use [a href=\"http://user.com/public/sitemap.php\" target=\"_blank\"]http://user.com/public/sitemap.php[/a] $this->homepage = "."; # http path to images $this->img_src = "/images"; # alternating row color; $this->alt_color = "on"; /* on/off */ $this->alt_color_one = "#f6f6f6"; $this->alt_color_two = "#c0c0c0"; # show directories first on/off $this->order = "on"; # blacklist file names and directories so they will not show $this->blacklist = Array(".", "..", .... rest of the code goes here.... Please can someone help me to get right these values $this->directory_root = "."; $this->homepage = "."; automatically from the server? Thanks in advance James
  3. Hi, I have a script in which I need to get these two values automatically: # full root path to directory (ie: /www/data/docs/user.com/public) $this->directory_root = "."; # http path to directory (ie: [a href=\"http://user.com/public)\" target=\"_blank\"]http://user.com/public)[/a] (no trailing slash) # Note: this must be a directory path you cannot use [a href=\"http://user.com/public/sitemap.php\" target=\"_blank\"]http://user.com/public/sitemap.php[/a] $this->homepage = "."; I have try to replace the first $this->directory_root = "."; with: $this->directory_root = "$_SERVER['DOCUMENT_ROOT'] . dirname(__FILE__)"; But I'm sure I get it wrong somehow. And the second part I also can't get it to work either. See more here: ############################## CONFIGURATIONS ################################# # html page on/off toggle writing of html header and footer $this->html = "on"; # width of <table> $this->table_width = "100%"; # on/off $this->debug = "off"; /* turn off/on display of working path. not recommened to leave on during public use. */ # full root path to directory (ie: /www/data/docs/user.com/public) $this->directory_root = "."; # http path to directory (ie: [a href=\"http://user.com/public)\" target=\"_blank\"]http://user.com/public)[/a] (no trailing slash) # Note: this must be a directory path you cannot use [a href=\"http://user.com/public/sitemap.php\" target=\"_blank\"]http://user.com/public/sitemap.php[/a] $this->homepage = "."; # http path to images $this->img_src = "/images"; # alternating row color; $this->alt_color = "on"; /* on/off */ $this->alt_color_one = "#f6f6f6"; $this->alt_color_two = "#c0c0c0"; # show directories first on/off $this->order = "on"; # blacklist file names and directories so they will not show $this->blacklist = Array(".", "..", .... rest of the code goes here.... Please can someone help me to get right these values $this->directory_root = "."; $this->homepage = "."; automatically from the server? Thanks for your help in advance
×
×
  • 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.