...

View Full Version : Javascript in php



Ludatha
02-19-2008, 11:47 PM
Hi, my chat script uses javascript, but when I want to display the name I want to use the name of the person logged in...
But how do I put something like

$_SESSION["username"]

Where it says THIS IS THE NAME



param += '&name=THIS IS THE NAME';

Now I don't know if this is possible, because PHP is server-side and Javascript is client-side.

Any Ideas?

StupidRalph
02-19-2008, 11:49 PM
Yes...


param += '&name= <?php echo $_SESSION["username"]; ?>';

Javascript has no idea and doesn't care if PHP wrote that value in.

Ludatha
02-20-2008, 12:12 AM
Oh, ok, I swear I tried that... :D

Thankyou :)

GO ILLINI
02-20-2008, 01:13 AM
you may also use the less code intensive option of:


<?=$_SESSION['username'];?>


-Adam

rafiki
02-20-2008, 02:31 AM
only if short tags is allowed.

StupidRalph
02-20-2008, 02:52 PM
Yeah I actually had the short tag version then changed it as to not make the assumption that he had short tags turned on. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum