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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.location.reload

    im have this small piece of php code where it simply reloads the pageand changes th eid room but must keep the username the same.

    the file checkuser.php passes the $username variable to login_success.php

    this piece of code is in login_success.php

    PHP Code:
    <SCRIPT>
    var enablecookies="<?php echo $_REQUEST['on'?>";
    var enablemenu="no";
    var roomID = '<?php echo $roomID ?>';
    var width = 600;
    var height = 360;
    var name = '<?php echo $username ?>';
    var mode = 0;
    </script>

    function Room1()
    {
        window.location.reload('login_success.php?roomID=961&username=$username');
    }
    The code above works for the roomID but the username always changes, it must be the value from '<?php echo $username ?>' but i am not sure how to keep it constant.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kurdishvoice
    window.location.reload('login_success.php?roomID=961&username=$username');
    you can't have the above in PHP. enclosing any variables inside single quotations, treats the entire thing as a string and therefore the variable doesn't get parsed.

    you should use double quotes like this instead:

    PHP Code:
    window.location.reload("login_success.php?roomID=961&username=$username"); 
    or even like so:

    PHP Code:
    window.location.reload('login_success.php?roomID=961&username='.$username); 
    *keep it simple (TM)

  • #3
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok the code that seems to half work is this, the username remains the same and so does the roomID.

    PHP Code:
    function Room1()
    {
        
    window.location.reload('login_success.php?roomID=962&username='.$username);


    But that code has one problem the roomID does not change it always stays at 961, i needed the roomID to change. However if i was to right it like this

    PHP Code:
    window.location.reload('login_success.php?roomID=962&username=.$username'); 
    Then the roomID changes and so does the username but the username must remain constant.

  • #4
    New to the CF scene
    Join Date
    Feb 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape

    Quote Originally Posted by kurdishvoice
    im have this small piece of php code where it simply reloads the pageand changes th eid room but must keep the username the same.

    the file checkuser.php passes the $username variable to login_success.php

    this piece of code is in login_success.php

    PHP Code:
    <SCRIPT>
    var enablecookies="<?php echo $_REQUEST['on'?>";
    var enablemenu="no";
    var roomID = '<?php echo $roomID ?>';
    var width = 600;
    var height = 360;
    var name = '<?php echo $username ?>';
    var mode = 0;
    </script>

    function Room1()
    {
        window.location.reload('login_success.php?roomID=961&username=$username');
    }
    The code above works for the roomID but the username always changes, it must be the value from '<?php echo $username ?>' but i am not sure how to keep it constant.


  •  

    Posting Permissions

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