SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: A strange one?

  1. #1
    SitePoint Member Cas's Avatar
    Join Date
    Jun 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A strange one?

    somthing weird is going on...
    I have run this script on my web server :

    //------
    <?
    session_start();
    session_register("SESSION");

    if (! isset($SESSION)) {
    $SESSION["count"] = 0;
    echo "<li>Counter initialized, please reload this page to see it increment";
    } else {
    echo "<li>Waking up session $PHPSESSID";
    $SESSION["count"]++;
    }
    echo "<li>The counter is now $SESSION[count] ";
    ?>

    //-------

    It does what it should, count + 1 every time it is refreshed. This proves that sessions are working on my ISP

    The below script from Kevins tutorial does not work on my ISP's internet server in the sense that if you try to access a page where you have added an include (all includes are in the same folder) to this script the page repeatedly asks for the user name and pass. I had one idea that maybe the session id was not being passed on to the next page. However the script works perfectly on my home PC....set up with Xtami server and mysql... Strange. My ISP is running Apache and Mysql.


    the script
    //----------------
    <?php // accesscontrol.php

    include("common.php");
    include("db.php");

    session_start();

    if(!isset($uid)) {





    ?>






    <html>
    <head>
    <title> Please Log In for Access </title>
    </head>
    <body>
    <h1> Login Required </h1>
    <p>You must log in to access this area of the site. If you are
    not a registered user, <a href="signup.php">click here</a>
    to sign up for instant access!</p>
    <p><form method="post" action="<?=$PHP_SELF?>">
    User ID: <input type="text" name="uid" size="8"><br>
    Password: <input type="password" name="pwd" SIZE="8"><br>
    <input type="submit" value="Log in">
    </form></p>
    </body>
    </html>

    <?php
    exit;

    }

    session_register("uid");
    session_register("pwd");

    dbConnect("optical");
    $sql = "SELECT * FROM user WHERE
    userid = '$uid' AND password = ('$pwd')";
    $result = mysql_query($sql);if (!$result) {
    error("A database error occurred while checking your ".
    "login details.\\nIf this error persists, please ".
    "contact me@Myweb.Net");
    }

    if (mysql_num_rows($result) == 0) {
    session_unregister("uid");
    session_unregister("pwd");
    ?>
    <html>
    <head>
    <title> Access Denied </title>
    </head>
    <body>
    <h1> Access Denied </h1>
    <p>Your user ID or password is incorrect, or you are not a
    registered user on this site. To try logging in again, click
    <a href="<?=$PHP_SELF?>">here</a>. To register for instant
    access, click <a href="signup.php">here</a>.</p>
    </body>
    </html>
    <?php
    exit;
    }
    $username = mysql_result($result,0,"fullname");
    ?>
    //---------

    Thank you to anyone offering help in advance.
    Just one more quick thing how does everyone get colour coded PHP like in many of the posts I read.
    thanks again
    Cas
    Last edited by Cas; Jul 12, 2001 at 11:21.
    "Tell me and I will forget , show me and I'll learn.
    Involve me and I will remember. " Confucius.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't answer your problem with the sessions.

    But to format your code for posting in these forums read:
    http://sitepointforums.com/misc.php?s=&action=bbcode


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
  •