Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20

MySQL // .php help :S

This is a discussion on MySQL // .php help :S within the Tech Support forums, part of the Knight Online (ko4life.com) category; if it didnt work , ill have to try the script myself that way will be easy to fix you ...
Page: 2


  1. #16
    Banned
    Join Date
    Jan 2007
    Posts
    353

    Default

    if it didnt work , ill have to try the script myself that way will be easy to fix

    you can link me the script in pm if its private

  2. #17
    Banned
    Join Date
    Dec 2007
    Posts
    1,195

    Default

    Code:
    <?php
    
    //Database Information
    
    $dbhost = "EDITED OUT";
    $dbname = "EDITED OUT";
    $dbuser = "EDITED OUT";
    $dbpass = "EDITED OUT";
    
    //Connect to database
    
    mysql_connect( $dbhost, $dbuser, $dbpass) or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    
    session_start();
    $username = mysql_real_escape_string(addslashes($_POST[&#39;username&#39;]));
    $password = md5($_POST[&#39;password&#39;]);
    
    $query = "select * from users where username=&#39;$username&#39; and password=&#39;$password&#39;";
    
    $result = mysql_query($query);
    
    if (mysql_num_rows($result) != 1) {
    $error = "Bad Login";
    ****include("login.html");
    
    } else {
    ****$_SESSION[&#39;username&#39;] = "$username";
    ****include("memberspage.php");
    }
    
    ?>
    Should work, haven&#39;t coded PHP in years. Also, please don&#39;t use public scripts, they&#39;re easily bypassed. Notice how I called Mysql_Real_Escape_String for the username? This is because the script in its current state (had it worked) would have been SQL Injectible. Give me a PM if this doesn&#39;t work or if you have any other needs.[/b]

    wow thanks man this one worked now you wouldn&#39;t happen to know how i can protect pages on my website so that you have to be logged in to view that page?

  3. #18
    Banned
    Join Date
    Dec 2007
    Posts
    1,195

    Default

    wow thanks man this one worked now you wouldn&#39;t happen to know how i can protect pages on my website so that you have to be logged in to view that page?[/b]
    nvm, this did nothing :S now any id and psw you enter works


    EDIT: figured out problem, fixed now

  4. #19
    NosferatuSoldier
    Guest

    Default

    PM me if there are any other questions.

  5. #20
    Banned
    Join Date
    Dec 2007
    Posts
    1,195

    Default

    PM me if there are any other questions.[/b]
    pm&#39;ed ^.^

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •