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 6 of 6
  1. #1
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts

    Javascript in php

    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
    PHP Code:
    $_SESSION["username"
    Where it says THIS IS THE NAME


    Code:
    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?

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Yes...

    PHP Code:
    param += '&name= <?php echo $_SESSION["username"]; ?>';
    Javascript has no idea and doesn't care if PHP wrote that value in.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • Users who have thanked StupidRalph for this post:

    Ludatha (02-19-2008)

  • #3
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts
    Oh, ok, I swear I tried that...

    Thankyou

  • #4
    Regular Coder GO ILLINI's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    634
    Thanks
    0
    Thanked 7 Times in 7 Posts
    you may also use the less code intensive option of:
    PHP Code:
    <?=$_SESSION['username'];?>
    -Adam
    Why not thank me?

    http://adamsworld.name

  • #5
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    only if short tags is allowed.

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Yeah I actually had the short tag version then changed it as to not make the assumption that he had short tags turned on.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

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