SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help me with this php code

    I have got two problems. I have an application that was developed using php 5 ,apache 1.3.3 and Mysql 4.1. The system or application was running with out problem. But when I installed php 5.2, apache 2.2.2 and mysql 5.0.
    I have started experiencing the following problems;



    First problem


    when I type url or browser this page problem.php I get the following code in the browser.

    "); } if ($_SESSION['Class'] != "Accounts") { echo "
    "; echo"Your are not authorised to access this area -You do not have enough privelages to access this area-LOGIN"; exit(); } ?>



    The above page ( problem.php) has the following php script for security. meaning the code below is to check if the user has logged in



    <?
    session_start();
    if(!isset($_SESSION['auth'])){
    echo"Sorry you have to login first, you will be redirected to the login page in a short while";
    echo "<br>";
    echo("<meta http-equiv=\"Refresh\" content=\"2; URL=http://localhost/subsistence/AccountsDepartment/Main_login_Accounts.php\">");
    }
    if ($_SESSION['Class'] != "Accounts") {
    echo "<br>";
    echo"Your are not authorised to access this area -You do not have enough privelages to access this area-<a href='../AccountsDepartment/Main_login_Accounts.php'>LOGIN</a>";
    exit();
    }
    ?>

    Second problem


    when I submit some data to the server side. e.g when I want to login to a protected page. I type in username and password then submit page or form I get the following two errors.



    1 Sometimes I get the following error



    You are not authorized to view this page
    You might not have permission to view this directory or page using the credentials you supplied.
    --------------------------------------------------------------------------------
    If you believe you should be able to view this directory or page, please try to contact the Web site by using any e-mail address or phone number that may be listed on the localhost home page.
    You can click Search to look for information on the Internet.

    HTTP Error 403 - Forbidden
    Internet Explorer

    in browser I can see the following <?%20echo%20$resultpage1;%20?>?sid=

    2



    OR Sometimes I get the following error


    Get I blank page and when I view source I see the following code

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
    <BODY></BODY></HTML>

    ?>
    Your help will be highly appreciated.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your using short tags eg <? ?> as php tags.

    this is an option that must be enabled in php.ini

    you could enable that option if you like and your code will work. but as you can see, having php code that relys upon that option is bad php code, because it is spilled as raw text to the browser when that option is disabled!

    the best soltuion, is to just replace <? with the real php tag which is <?php

    you need to do that in ever file, but the find/replace utility in your text editor should make short work of this.

  3. #3
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Clamcrusher .
    It worked


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
  •