+ Reply to Thread
Results 1 to 4 of 4

Thread: Having Problems with login script.

  1. #1
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Having Problems with login script.

    PHP Code:
    <?php
    include('connect.php');
    if(
    $loggedin == '0'){if(isset($_POST['submit'])){
    // Make sure all forms were filled out.
    if((!isset($_POST['username'])) || (!isset($_POST['pass']))|| ($_POST['username'] == '') || ($_POST['pass'] == ''))die("Please fill out the form completely. <br><br><a href=index.php>Continue</a>");
    // Get user's record from database$player = @mysql_query("SELECT id, username, password, registered, lastlogin FROM players WHERE username = '".$_POST['username']."'");$player = @mysql_fetch_assoc($player);
    if($player['id'] == false)die("Sorry, that user is not in our database.<br><br><a href=index.php>Back</a>");else if($player['password'] != md5($_POST['pass']))die("Wrong password!<br><br><a href=index.php>Back</a>");
    // set session variables$_SESSION['id'] = $player['id'];$_SESSION['username'] = $player['username'];$_SESSION['password'] = $player['password'];
    // update last login$date = date("m/d/y");
    $update = @mysql_query("UPDATE players SET lastlogin = '$date' WHERE id = '".$_SESSION['id']."'");
    echo 
    'You are now logged in!';
    }else{echo 
    'You are not logged in. <br><br><form action=index.php method=post>Username: <input type=text name=username><br>Password: <input type=password name=pass><br><input type=submit name=submit value=Submit></form>Would you like to <a href=register.php>register?</a>';}}else{echo 'You are logged in! Welcome to my game, '.$_SESSION['username'].'!<br><br><a href=logout.php>Click Here to Logout</a>';
    }
    ?>
    That is what I am using on my index.html page. But it doens't work/ shows up in the html. How so I stop it from doing that and making it work? The register script I'm using doen't seem to work either. Make me think that something if off in my database...
    PHP Code:
    <?php
    include('connect.php');

    if(
    $loggedin == '1')
    die(
    "You can't register another account while you're logged in.");

    // Register Script
    // So, the register script is a sample of the basic elements of 
    // coding used in a simple sim game, namely, putting new data 
    // into databases.

    if(isset($_POST['submit']))
    {

    // trim removes the whitespaces from the beginning and end of text
    // this keeps someone from having a username of " "
    $uname trim($_POST['username']);

    // Make sure all forms were filled out.

    if((!isset($_POST['username'])) || (!isset($_POST['pass']))
    || (
    $uname == '') || ($_POST['pass'] == ''))
    die(
    "Please fill out the form completely. <br><br>
    <a href=register.php>Continue</a>"
    );

    // Make sure name hasn't already been used.
    $check = @mysql_query("SELECT id FROM players WHERE username = '$uname'");
    $check = @mysql_num_rows($check);

    if(
    $check 0)
    die(
    "Sorry, that username has already been taken. Please try again.
    <br><br>
    <a href=register.php>Continue</a>"
    );

    // Encrypt password
    $pass md5($_POST['pass']);

    $date date("m/d/y");

    // Finally, create the record.
    $newPlayer = @mysql_query("INSERT INTO players (username, password, registered) VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error());

    echo 
    'You have been registered! You may now <a href=index.php>Log in</a>.';


    }
    else
    {

    // A simple example of a form.

    echo '<form action=register.php method=post>
    Username: <input type=text name=username><br>
    Password: <input type=password name=pass><br>
    <input type=submit name=submit value=Submit>
    </form>'
    ;

    }


    ?>
    Can anyone help/point out what is wrong? What can I use that will work? I'm totally lost. O.o

  2. #2
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Having Problems with login script.

    Moved to site management

  3. #3
    esoterikdesign is offline x10Hosting Member esoterikdesign is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    3

    Re: Having Problems with login script.

    Well, for PHP scripting to be parsed, it must be placed on a page with an extension that will have that done; you may want to try renaming your index with a .php extension rather than .html.

  4. #4
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Having Problems with login script.

    I tried that. it still won't work.
    Edit:
    anyone?
    Edit:
    I figured it out thanks.
    Last edited by salukigirl; 09-17-2007 at 08:12 PM. Reason: Automerged Doublepost

+ Reply to Thread

Similar Threads

  1. Login script not working on x10 but works on home server
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 01-03-2007, 01:34 AM
  2. Secure login script question
    By cetutnx1 in forum Free Hosting
    Replies: 0
    Last Post: 05-01-2006, 05:40 PM
  3. Cant login to my news script
    By SecureStealth in forum Free Hosting
    Replies: 0
    Last Post: 09-08-2005, 05:47 PM
  4. PHP login script
    By xunhandmex in forum Scripts & 3rd Party Apps
    Replies: 8
    Last Post: 05-26-2005, 07:56 PM

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