Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    newbie sessions problem

    Just a quick one - I have secure login script that is working perfectly on my laptop (WAMP) using PHP5, and it will not function whatsoever on PC with same WAMP configuration. It seems to have a problem with sessions and is just showing garble on the screen. I have checked the obvious like accepting cookies and seems okay. The code is the exact same as on laptop... Would it be a problem with where and if the cookies are being writen to, or am I making no sense at all....? doh.

    I am pretty newbie to this, but it seems like a fixable problem as I got it running on laptop.. All help much apprecaited..

    greetings from Ireland!

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,066
    Thanks
    2
    Thanked 319 Times in 311 Posts
    For anyone in a Forum to be able to help, we need to see what you see. Post your code and post the garble that you are getting as output.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    it will not function whatsoever on PC with same WAMP configuration
    Can u tell us what error you are getting or its just showing blank screen


    greetings from Ireland!
    I like greetings from Ireland

  • #4
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hi - thanks for the replies guys.

    Basically, I have used the scripts from Login System v2.0 at http://www.evolt.org/PHP-Login-Syste...ts_per_page=50

    I have incorporated it in my own site all ok, but will not work in another PC with same config (WAMP). MySQL appears to be okay etc...

    This is a copy of what I get when looking at main.php (this is a screen print)
    You will have to excuse me a little guys as this is my frst posting.

    thanks - dave :-)

    ------------------
    logged_in){ echo "
    Logged In
    "; echo "Welcome $session->username, you are logged in.

    " ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ ?>
    Login
    num_errors > 0){ echo "".$form->num_errors." error(s) found"; } ?>
    Username: "> error("user"); ?>
    Password: "> error("pass"); ?>
    value("remember") != ""){ echo "checked"; } ?>> Remember me next time

    [Forgot Password?]

    Not registered? Sign-Up!


    "; echo "Member Total: ".$database->getNumMembers()."
    "; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.

    "; include("include/view_active.php"); ?>

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    PHP Code:
    logged_in){ echo "
    Logged In
    "
    ; echo "Welcome $session->username, you are logged in.

    ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ ?>
    Login
    num_errors > 0){ echo "".$form->num_errors." error(s) found"; } ?>
    Username: "> error("user"); ?>
    Password: "> error("pass"); ?>
    value("remember") != ""){ echo "checked"; } ?>> Remember me next time

    [Forgot Password?]

    Not registered? Sign-Up!


    "; echo "Member Total: ".$database->getNumMembers()."
    "; echo "There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.

    "; include("include/view_active.php"); ?> 
    sorry just for easier readability

  • #6
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    your closing the PHP param tags ?>
    PHP Code:
    logged_in){ echo "
    Logged In
    "
    ; echo "Welcome $session->username, you are logged in.

    ."[username\">My Account] " ."[Edit Account] "; if($session->isAdmin()){ echo "[Admin Center] "; } echo "[Logout]"; } else{ 
    num_errors 0){ echo "".$form->num_errors." error(s) found"; } 
    Username: > error("user"); 
    Password: > error("pass"); 
    value("remember") != ""){ echo "checked"; }


     echo 
    "Member Total: ".$database->getNumMembers();
     echo 
    "There are $database->num_active_users registered members and "
    echo 
    "$database->num_active_guests guests viewing the site.";
     include(
    "include/view_active.php"); ?> 
    some of this stuff doesnt make sense.
    Last edited by rafiki; 02-22-2008 at 12:28 PM.

  • #7
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks for that rafiki -

    the element you have made easier to read was actually the screen output when browsing main.php - not the actual code...

    Is there an easier way to dump this screenprint to show the errors I am getting? Sorry for the confusion.

    Dave
    Wow - I did'nt know that !!!

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    you have a URL? then we can all see what the errors are.

  • #9
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    its on a local host at the moment - i will put it online if you give me a few minutes there....

    thanks for your help...
    Wow - I did'nt know that !!!

  • #10
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,066
    Thanks
    2
    Thanked 319 Times in 311 Posts
    The code is using the lazy-way short open tags - <? (and probably <?=), which makes the code non-portable between servers with different settings. Even php.net recommends that short open tags are not used on code that might be publicly distributed -

    ; NOTE: Using short tags should be avoided when developing applications or
    ; libraries that are meant for redistribution, or deployment on PHP
    ; servers which are not under your control, because short tags may not
    ; be supported on the target server. For portable, redistributable code,
    ; be sure not to use short tags.
    You could turn on short open tags, but it would be much better to correct the code, because if you change hosts at some time in the future, you might get one where short open tags are off (they also cause a problem with <?xml tags) and you won't have the ability to turn them on.

    So, change any <? to <?php and any <?= to <?php echo to fix the code so that it will work independent of the short tag setting.

    Short open tags are such a huge problem that while php.net is not currently planning on eliminating them in php6, they are considering putting in a test that will generate an error when mixing <? and <?php within the same file, to enforce consistency (I suspect that the top dog at php.net won't allow them to be eliminated, sadly, but doing so would force people to write code that would always work and would eliminated posts like this in help forums where code works on one server and not another.)
    Last edited by CFMaBiSmAd; 02-22-2008 at 01:00 PM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #11
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for that - I was not aware of that and will correct the code.

    I am not sure if this is the problem in this instance however, as the code is not hosted at the moment. The same code, apart from MySQL connection strings, is exactly the same - it is running perfect on my XP laptop on WAMP config, no problems. When I try the same on a XP desktop it is giving me problems with sessions - at least from what I can make out. Running the same code withou the login scripts runs just fine, and is using MySQL, but no sessions. I guess my question really is if there is something obvious that I am missing? Cookies are enabled and I can see that PHPSESSID has a cookie session. Could it be that the are not being written / saved properly?

    Hope this makes sense...

    Dave
    Wow - I did'nt know that !!!

  • #12
    New Coder
    Join Date
    Feb 2008
    Location
    Cork- Ireland
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts
    sorry - i forgot to mention that i am using localhost on both machines...
    Wow - I did'nt know that !!!

  • #13
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,066
    Thanks
    2
    Thanked 319 Times in 311 Posts
    Turning on full php error reporting and/or checking your web server log files for errors will tell you of any problems that php detects while running your code, such as problems with headers being sent, session save path settings...

    Turning on full error reporting in php.ini (or a .htaccess file) is best because it will also cause fatal parse errors to be displayed. Change the following two lines in php.ini and stop and start your web server to get any changes made to php.ini to take effect -

    Code:
    error_reporting  =  E_ALL | E_STRICT
    display_errors = On
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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