Web Analytics Made Easy -
StatCounter What do the different bits of this code do? - CodingForum

Announcement

Collapse
No announcement yet.

What do the different bits of this code do?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What do the different bits of this code do?

    Hello,

    I am doing a user authentication script, and I want it to only check the username not the ip address for authorisation. The code I have is this:

    PHP Code:
    session_start(); 
    $newip $_SERVER['REMOTE_ADDR']; 
    if (!isset(
    $_SESSION['username']) ¦¦  
    empty($_SESSION['username']) ¦¦ $newip!= $_SESSION['ip']) { 
     include 
    "logout.php"

    First of all, this code on its own has syntax errors that I cannot find. Any light on this would be great.

    Secondly, I want to change this code so it only checks the username and not the ip address. How do I do this. Part of my confusion was the strange ¦ symbol????

    Thanks Jake

  • #2
    The errors are being caused by the split vertical bars. Changing them to sold vertical bars will solve the syntax error. To not check the address simply remove its OR condition from the if statement.

    PHP Code:
    session_start();
    if (!isset(
    $_SESSION['username']) || empty($_SESSION['username'])) {
     include 
    "logout.php";

    Dave .... HostMonster for all of your hosting needs

    Comment


    • #3
      Hi,

      Thanks so much for your reply.
      I think we are on the right tracks here, but I am still get a 'Unexpected T_STRING error' on the second line. What does this mean and how can I fix it?

      Thanks Jake

      Comment


      • #4
        I'm positive that if you copied what I posted you will not get an error from those 4 lines alone. If that is part of a larger program post it please. It is quite likely the error is not at all related to the small portion I posted.
        Dave .... HostMonster for all of your hosting needs

        Comment


        • #5
          Ahh, my fault, sorry. It works perfectly, thanks so much

          Comment

          Working...
          X