Page 1 of 2 1 2 LastLast
Results 1 to 15 of 21

Thread: session problem in localhost

  1. #1
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0

    session problem in localhost

    aku pakai apache 2.0.47
    mysql 4.014b
    dan php 4.3.3
    dlm winXP

    aku nak tanya pasal this command:

    session.save_path = C:/php/foldersimpansession

    apsal bila aku set ni dlm php.ini aku still bila test
    pakai phpinfo() tu dia masih keluar /tmp (yg default)

    mmm... sapa2 leh tolong aku.. tima kasih
    ::nevland:: the land of nowhere

  2. #2
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    248
    something to do with Apache httpd ?

  3. #3
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    i don't think it got stg to do with apache httpd.conf
    ::nevland:: the land of nowhere

  4. #4
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    Can you set a session? In other words, does sessions work?

  5. #5
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    no.. the session doesn't work.. that's why i'm asking this question..
    when i upload to my paid server... it works fine....
    ::nevland:: the land of nowhere

  6. #6
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    Hey,

    There are a few thing that you could do to try fix this:

    1) Make sure that C:/php/foldersimpansession exists then change your php.ini session.save_path to: C://php//foldersimpansession or C:\\php\\foldersimpansession
    (Note the double slash)
    -- OR --
    2) Make a tmp directory on the root of C, so C:/tmp and change your php.ini to: session.save_path = \tmp
    (It doesn't have to be tmp, could be anything really)

    This problem is not very common, because I have a box running the exact same version - Apache 2.47 and PHP 4.3.3 and the default save_path is C:\PHP\sessiondata

    But try one of those two (or both) and see if it helps.
    Last edited by sufyan; 02-10-2003 at 09:25 AM.

  7. #7
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    thanks sufyan for your help..

    last night got it working already..
    i did what u told me before... it just doesnt work..
    and i found out that when i put php.ini into my c:\windows
    then it works..
    before it was only in my c:\windows\system32\
    ::nevland:: the land of nowhere

  8. #8
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    Ah, that why... no problems...

  9. #9
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    need helps.. / opinions.

    currently i've two tables one is for users login info = users
    the other is users' profile = profile

    users login would have username & password and id fields

    profile would have more info about users.

    id in table users is set to be primary.

    my question.. do i really need to have two tables or just dump the whole things in one table? if i have two, i need to have a field in table profile that refer to table 1 = users.. am i right?

    ok, let's say i want to authenticate using the users table then redirect to display user profiles from profile table.. how do i do that..?

    tq. so much.
    ::nevland:: the land of nowhere

  10. #10
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    Hi there,

    It depends on how your designing your system/how you want it to work. If each user only has ONE profile, the best thing to have is only one table. If the user may have more than one profile, you would need two seperate tables.

    Each of your tables should have a key and you can use these keys to indentify the record and what it belongs to. So for example, you have a user, Jim, with the ID# 1 in the user table, the other table (profiles) will use that key as reference. So if you want to view Jim's profile you would select it from the database where UserID = 1.

    ok, let's say i want to authenticate using the users table then redirect to display user profiles from profile table.. how do i do that..?
    Just use the regular login script - make the script create a session with the ID key from the user table. Once you have that session, you can get directed to the profile page (or any other page) and view the profile from there. To get the profile, just select from the database using something like:

    SELECT * FROM Users WHERE ID=" . $_SESSION["UserID"]

    After that just use your regular code to print/display the profile once it has been selected.

  11. #11
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    thanks man..

    here have a look with my authentication script..

    sape2 yg terror tolong tgk coding ni..

    PHP Code:
    <?
    /* authenticate script */
    session_start();  // Start Session

    include 'db_config.php';
    // Conver to simple variables
    $username $_POST['username'];
    $password $_POST['password'];

    if((!
    $username) || (!$password)){
        echo 
    "Please enter ALL of the information! <br />";
        include 
    'enter.html';
        exit();
    }

    // Convert password to md5 hash
    $password md5($password);

    // check if the user info validates the db
    $sql mysql_query("SELECT * FROM myprofile WHERE username='$username' AND password='$password'");
    $login_check mysql_num_rows($sql);

    if(
    $login_check 0){
        while(
    $row mysql_fetch_array($sql)){
            foreach( 
    $row AS $key => $val ){
                $
    $key stripslashes$val );
            }
            
    // Register some session variables!
            
    session_register('username');
            
    $_SESSION['username'] = $username;
            
    header("Location: profile.php");
        }
    } else {
        echo 
    "You could not be logged in! Either the username and password do not match!<br />
        Please try again!<br />"
    ;
        include 
    'enter.html';
    }
    ?>

    nama file ni aku bagi auth.php
    dekat form html aku yg ada login info (username, password) aku taruk lah form action ="auth.php" ...

    what do you think..? i havent' got this work though..
    Last edited by nevland; 08-10-2003 at 07:30 PM.
    ::nevland:: the land of nowhere

  12. #12
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    hey there...

    just one question... in your database are the password md5 encrypted? If not... that's you problem.

    By the way, that script is terrible. There is a very obvious backdoor. If I knew a user name to your site, for example 'jim' was a registered user, i could type:

    Username: jim'"); //
    and typed anything in the password field and it would accept it.

    When thats done, your *effective* script looks smthing like this:

    $sql = mysql_query("SELECT * FROM myprofile WHERE username='jim'"); //' AND password='$password'");

    See what it does... it comments out ' AND password='$password'"); bypassing the password check making your *authenticate* script useless.
    Last edited by sufyan; 08-10-2003 at 04:46 PM.

  13. #13
    Join Date
    May 2002
    Posts
    23
    Rep Power
    0
    yeah.. my db is md5 encrypted..

    so.. what do you think it supposed to be..?
    coz it just doesn't go to the next page: profile.php
    ::nevland:: the land of nowhere

  14. #14
    Join Date
    Oct 2001
    Location
    Melbourne, AU
    Posts
    456
    Rep Power
    227
    hey, i think it would be easier if u zipped & attached the whole script (with the sql dump), because i don't see anything wrong with the code.

  15. #15
    Join Date
    Jan 2003
    Location
    dreamland
    Posts
    240
    Rep Power
    207
    caya la sufyan... sbijik cam aku buat...
    huhauhuhhahhahahha....
    explain terbaik camtu pun nevland tak paham....
    aku rasa nevland ader buat silap skit ler kat coding dier...
    try to fix it... aku pun tak paham gak nevland nyer masalah..
    ^_^ <== stay happy

Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. sharing the localhost for easyphp
    By linmsa3 in forum Website Programming
    Replies: 1
    Last Post: 08-12-2009, 05:52 PM
  2. localhost machine software
    By calvynlee in forum Mamak Stall
    Replies: 12
    Last Post: 20-11-2006, 02:57 PM
  3. Session Problem
    By koisempoi in forum Website Programming
    Replies: 6
    Last Post: 22-12-2005, 05:27 PM
  4. can't connect to mysql server on localhost
    By nurulmajdi in forum Website Programming
    Replies: 6
    Last Post: 16-02-2004, 03:57 PM
  5. Does we need iis to set php as my localhost server
    By Syazwan in forum Website Programming
    Replies: 15
    Last Post: 07-10-2003, 08:30 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
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112