#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0

    Question PHP and Javascript?!?


    I have two frames on a site. Head- and main-Frame!
    After a login on the main-Frame the head-frame should show the name of the user.

    With header ("Location: head?user=$user); I get what I need but not in the head-Frame.

    In Javascript I have tried it with:
    => parent.head.location="head.php?user=$user"
    but here the variable $user is not recognized from the script!

    I hope somebody can help me!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Posts
    679
    Rep Power
    18
    php variables are only available to php, not in javascript or html. You will have to send your script to php to output the variable, before it comes to the browser, which is where javascript is running. So, assuming the bit of javascript you posted is within a php script, change it to:
    => parent.head.location="head.php?user=<?php echo $user ; ?>"
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    102
    Rep Power
    13
    try:

    parent.head.location="head.php?user=<?=$user;?>"

    remember: if you want to use php vars you need to be between php tags
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0
    THX => That was a realy fast answer and it works!
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0
    Is it possible to make this without javascript.
    header("Location: ") ???
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    102
    Rep Power
    13
    yes:
    header("Location: head.php?user=$user");
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    16
    Rep Power
    0
    OK with "header ("Location: ...")", but I want it in another frame.
    Not in the frame where I am.

    Something like Location.head ... ???
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2001
    Posts
    102
    Rep Power
    13
    try this:

    link

IMN logo majestic logo threadwatch logo seochat tools logo