SitePoint Sponsor

User Tag List

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

    Help on Undefined variable and Javascript

    Hello,
    I have problem with some errors. There are some applications that I did in php using mysql database. these systems used to run with out any error. These versions were php 5, mysql 4.1 and apache 1.3.3. Now I have moved to mysql 5.0, apache 2.2.2 and php 5.2.

    Now have been receiving errors saying "Undefined variable" even if I have assigned a variable.

    Second is javascripts
    Iam not able to echo a php using javascript.
    I had writtern a php script below such that if the user enters correct username and pasword it should take him/her to a different page but it is not working now .
    The code is below.

    $result2 = mysql_query($query2);

    $result = mysql_query($query);


    if ((mysql_fetch_row($result)) and (mysql_fetch_row($result2))){

    echo "Welcome To Accounts Department";
    /* Allow access if a matching record was found, else deny access. */
    $_SESSION['Username'] = "Username";
    $_SESSION['Password'] = "Password";
    $_SESSION['EmployeeNumber'] = "EmployeeNumber";
    $_SESSION['key1']=$zrb;
    $_SESSION['kite']=$zrc;
    $_SESSION['kite2'] = $zra;
    $_SESSION['Class'] = $zrfw8;
    $_SESSION['auth']=true;
    session_write_close();

    $location = $resultpage1;
    ?>
    <HEAD>
    <script language="JavaScript1.1" type="text/javascript">
    <!--
    location.replace("<? echo $resultpage1; ?>?sid=<?php echo strip_tags($sid); ?>");
    //-->
    </script>
    </HEAD>
    <?



    } else {
    ?>
    <HEAD>
    <script language="JavaScript1.1" type="text/javascript">
    <!--
    location.replace("<? echo $resultpage2; ?>?sid=<?php echo strip_tags($sid); ?>");
    //-->
    </script>
    </HEAD>
    <?
    }






    ?>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Why have you got an echo before the <HEAD> tag?

    And your script as written makes no sense to me.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wht u r trying to do here

  4. #4
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, Iam trying to echo the page where a user who has logged sucessfully should go.
    If the script is checking the following

    $_SESSION['Username'] = "Username";
    $_SESSION['Password'] = "Password";
    $_SESSION['EmployeeNumber'] = "EmployeeNumber";
    $_SESSION['key1']=$zrb;
    $_SESSION['kite']=$zrc;
    $_SESSION['kite2'] = $zra;
    $_SESSION['Class'] = $zrfw8;
    $_SESSION['auth']=true;
    session_write_close();

    So if above are correct it should echo the page.
    That is what I want to achive?

  5. #5
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use header("location:login.php");


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
  •