Jump to content

ytmnd522

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by ytmnd522

  1. Hello guys.. Im having a hard time loging a user in. This is my script.. When I submit the data it just refreshes with no response if the user was found on da database or anything..what's up with my script.
    I have a mysql database named "mike" with a few records of users with passwords.
    thanks in advanced.

    [code]<? session_start()?>

    <html>
    <body>
    <form action="vtcsignin.php" method="post">
    users:
    <INPUT type="text" name="user"><br>
    password:
    <INPUT type="password" name="password"><br>
    <INPUT type="submit">
    </form>
    </body>
    </html>
    <?

    if(isset($_POST['user']) && isset($_POST['pass'])){
        if($logged_in_user == $user){
            echo $_POST['user'] . " Your are already logged in";
        exit;
        
        }
    }

    $db = mysql_connect("localhost","root") or die ("cant connect to database");
    mysql_select_db("mike", $db) or die("could not select database");
    $result = mysql_query("SELECT * FROM users WHERE userName = '".$user."' AND userPassword = PASSWORD('".$pass."')");

    if(!$result){
        print "no information brought back";
    }

    if(mysql_num_rows($result) > 0){
    $_SESSION['logged_in_user']=$user;
    echo "welcome, " . $user;
    exit;
    }elseif(mysql_num_rows($result)==0){
        echo "No record found in the database";
        session_destroy();
    }


    ?>[/code]
×
×
  • 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.