Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    hi all...

    i have several page ..in my website ..but i want a particualr web page to be locked so that no one sees it ..excpt the one who gives username and password..i use follwoing script ...

    LOGGING.html

    <html>
    <head>
    <title>login.html</title>
    </head>
    <body>
    <form name="login" method="post" action="validate.php">
    username:<input type="text" name="user_name"><br>
    password:<input type="password" name="password"><br>
    <input type="submit" value="submit">
    </form>
    </body>
    </html>

    validate.php

    <?php
    session_start();
    $db_user = 'mysql_username';
    $db_pass = 'mysql_password';
    $user_name = $_POST['user_name'];
    $password = $_POST['password'];

    //connect to the DB and select the "dictator" database
    $connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
    mysql_select_db('dictators', $connection) or die(mysql_error());

    //set up the query
    $query = "SELECT * FROM users
    WHERE user_name='$user_name' AND password='$password'";

    //run the query and get the number of affected rows
    $result = mysql_query($query, $connection) or die('error making query');
    $affected_rows = mysql_num_rows($result);

    //if there's exactly one result, the user is validated. Otherwise, he's invalid
    if($affected_rows == 1) {
    print 'validated';
    }
    else {
    print 'not valid';
    }
    ?>

    everything is allright ...but the problem is how should i redirect the user to my webpage and then after seeing how should i ask for logout ...

    one thing more ...if someone ask for that particualr webpage then he should be first asked for this authentication...

    pls help me out in this

  2.  

  3. #2
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Check this recent thread started by me:

    http://www.webdesignforums.net/php_a...ase_19076.html

    Majorly helpful for login scripts!
    Rednerve
    Creative Freelance Design

  4. #3
    Member Anant's Avatar
    Join Date
    Feb 2005
    Location
    Indore , India
    Posts
    50
    Member #
    9049
    well thats not the problem

    Quote Originally Posted by will7
    Check this recent thread started by me:

    http://www.webdesignforums.net/php_a...ase_19076.html

    Majorly helpful for login scripts!
    thanx for reading thorugh ..but my problem is never the connection ..it working well...what i want is that my particular webpage opens after passing correct username and passowrd....

    and for this i used this script..but it never directs me to that page....

  5. #4
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    Read farther into that link. Only the first part is about the connection. Myself, rosland, and will7 have been working on authentication scripts near the end of it. You'll see 2 working ones in there atm, and I'm going to throw up one from the php security mailing list when I get a chance.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  6. #5
    Member
    Join Date
    Jan 2005
    Posts
    97
    Member #
    8727
    Do session_start(), instead of echo ing validated set session thingies, then on log out session_destroy().
    Read through that topic, you've made a few very common mistakes in authentication.

  7. #6
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Yeah, use sessions. Read through that thread (it may take a while ). You will learn loads about sessions, logins and some of the problems I faced.
    Rednerve
    Creative Freelance Design


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:30 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com