Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-03-2004, 04:19 PM   PM User | #1
kurdishvoice
New to the CF scene

 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kurdishvoice is an unknown quantity at this point
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.
kurdishvoice is offline   Reply With Quote
Old 11-03-2004, 04:44 PM   PM User | #2
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
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)
jbot is offline   Reply With Quote
Old 11-03-2004, 05:36 PM   PM User | #3
kurdishvoice
New to the CF scene

 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kurdishvoice is an unknown quantity at this point
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.
kurdishvoice is offline   Reply With Quote
Old 02-18-2006, 05:04 PM   PM User | #4
skalla
New to the CF scene

 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
skalla is an unknown quantity at this point
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.
skalla is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:01 AM.


Advertisement
Log in to turn off these ads.