+ Reply to Thread
Results 1 to 3 of 3

Thread: Is this safe?

  1. #1
    Shadow121's Avatar
    Shadow121 is offline x10 Lieutenant Shadow121 is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Centerville
    Posts
    455

    Is this safe?

    Can someone please tell me if this is safe then maybe suggest ways to make it safer?

    The function Encode is using md5(sha1()); for protection.
    Code:
    <?php
    if(!isset($_SESSION[logged_in]) && !$logged[username] && !$_POST[login]){
    echo "<form method='post' action='index.php?x=login'>
    <b>Username</b>:<br />
    <input type='text' name='user' size='15'><br />
    <b>Password</b>:<br />
    <input type='password' name='pass' size='15'><br />
    <input type='submit' name='login' value='Login'>
    </form>";
    }elseif(!isset($_SESSION[logged_in]) && !$logged[username] && $_POST[login]){
    $user = mysql_real_escape_string(stripslashes($_POST[user]));
    $pass = Encode(stripslashes($_POST[pass]));
    if(empty($user) || empty($pass)){
    echo "<B>Error</b>: You Left A Field Blank";
    }
    $check = mysql_query("SELECT id, username, password FROM users WHERE username = '$user' AND PASS = '$pass' LIMIT 1");
    if(mysql_num_rows($check) > 0){
    $_SESSION[logged_in] = "1";
    $_SESSION[user] = $user;
    $_SESSION[pass] = $pass;
    echo "You Have Been Logged In Successfully <meta http-equiv=\"Refresh\" content=\"4;url= index.php?x=cp\">";
    }else{
    echo "<b>Error</b>: Invalid Password, Or user Does Not Exist.";
    }
    }elseif(isset($_SESSION[logged_in]) && $logged[username]){
    echo "<b>Error</b> You Are Already Logged In.<meta http-equiv=\"Refresh\" content=\"4;url= index.php?x=cp\">";
    }
    ?>

  2. #2
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

  3. #3
    Micro is offline Retired staff (11-12-2008) Micro is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    West Midlands
    Posts
    1,301

    Re: Is this safe?

    Just a hint, do a strip_tags on the username field -- if someone sneaks HTML into there, and you do something with it your users can really mess up your site, especially if their username is shown to other users.
    Micro

+ Reply to Thread

Similar Threads

  1. Is it safe to delete these?
    By YamiKaitou in forum Free Hosting
    Replies: 1
    Last Post: 01-25-2007, 12:24 PM
  2. PHP Safe mode?
    By poringy in forum Free Hosting
    Replies: 1
    Last Post: 11-17-2006, 02:19 AM
  3. Safe and Accessible Webdesign
    By IIN Operator in forum Tutorials
    Replies: 3
    Last Post: 06-02-2006, 05:24 AM
  4. Safe Mode?
    By RollerC in forum Free Hosting
    Replies: 7
    Last Post: 06-29-2005, 07:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers