Passing variables from PHP to Javascript and vice versa

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psyko514
    See sig. Join Epic Cash.
    • Oct 2002
    • 22366

    #1

    Passing variables from PHP to Javascript and vice versa

    i have a frames page with a menubar at top and the main content below. i want the main page to redirect to a PHP page based on screen size using the following format

    if (screen.width > 1024)
    {window.location.href='girls1024.php?id=XXXXX'}

    where XXXXX will be sent to JS from PHP

    i know very little about JS, so help me out here... thanks

    Bad Girl Bucks
    - 50% Revshare through CCBill.
    Promote BrandyDDD, Pixie's Pillows, Action Allie and more!

    Phoenix Forum Pics | Webmaster Access Montreal pics
    email: psyko514(a)gmail.com | icq: 214-702-014
  • Exxxotica
    Confirmed User
    • Jan 2001
    • 4396

    #2
    uhh....


    Needs some really great hosting? Black Seven

    note: I do not work for Blackseven... Im just grateful for their kick ass hosting...so quit bothering them when I hurt your feelings... pussy

    Comment

    • FATPad
      Confirmed User
      • Oct 2001
      • 6693

      #3
      Your main page has to set those values. They'll be part of the html document that is sent to the browser. Since it sounds like the main page will be dynamic in nature, whatever you use to build the main page should just fill that information in as part of the html document.
      <a href="http://www.adultcontent.co.uk">Adult Content UK - Great British Content</a>

      Comment

      • magnatique
        Confirmed User
        • Jan 2001
        • 1830

        #4
        (for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)

        ok assuming your page you are linking to is called

        www.domain.com/redir.php

        you'd link to it like

        www.domain.com/redir.php?id=magnatique

        then, on that redir.php page you'd have

        if (screen.width >= 1024)
        {window.location.href='girls1024.php?id=<* echo $id;*>'}
        else if (screen.width >= 800)
        {window.location.href='girls800.php?id=<* echo $id;*>'}
        else
        {window.location.href='girls640.php?id=<* echo $id;*>'}
        Last edited by magnatique; 12-05-2002, 09:47 PM.

        Stunner Media Programs: StandAhead | IndieBucks | BoyCrushCash | Phoenixxx | EmoProfits | BritishBucks | HunkMoney | LatinoBucks
        Make $$$ with Gay! Lowest Minimum Payouts in the Business, Perfect Track Record, Amazing Sites

        Comment

        • Exxxotica
          Confirmed User
          • Jan 2001
          • 4396

          #5
          uhh...


          Needs some really great hosting? Black Seven

          note: I do not work for Blackseven... Im just grateful for their kick ass hosting...so quit bothering them when I hurt your feelings... pussy

          Comment

          • psyko514
            See sig. Join Epic Cash.
            • Oct 2002
            • 22366

            #6
            i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.

            Originally posted by magnatique
            (for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)

            ok assuming your page you are linking to is called

            www.domain.com/redir.php

            you'd link to it like

            www.domain.com/redir.php?id=magnatique

            then, on that redir.php page you'd have

            if (screen.width >= 1024)
            {window.location.href='girls1024.php?id=<* echo $id;*>'}
            else if (screen.width >= 800)
            {window.location.href='girls800.php?id=<* echo $id;*>'}
            else
            {window.location.href='girls640.php?id=<* echo $id;*>'}

            Bad Girl Bucks
            - 50% Revshare through CCBill.
            Promote BrandyDDD, Pixie's Pillows, Action Allie and more!

            Phoenix Forum Pics | Webmaster Access Montreal pics
            email: psyko514(a)gmail.com | icq: 214-702-014

            Comment

            • Calvinguy
              Confirmed User
              • Oct 2002
              • 1752

              #7
              Originally posted by psyko514
              i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.

              Of course you can... JS is client based, PHP server based

              Comment

              • magnatique
                Confirmed User
                • Jan 2001
                • 1830

                #8
                php has to be enabled on the server ;)

                also, as I said, replace the * by ?


                whatever you put in a url like
                ?id=test

                you call it back ('test')
                by writing
                <* echo $id;*>

                where the * is a ?

                Stunner Media Programs: StandAhead | IndieBucks | BoyCrushCash | Phoenixxx | EmoProfits | BritishBucks | HunkMoney | LatinoBucks
                Make $$$ with Gay! Lowest Minimum Payouts in the Business, Perfect Track Record, Amazing Sites

                Comment

                • Rory
                  Confirmed User
                  • Jul 2002
                  • 616

                  #9
                  Originally posted by magnatique
                  php has to be enabled on the server ;)

                  also, as I said, replace the * by ?


                  whatever you put in a url like
                  ?id=test

                  you call it back ('test')
                  by writing
                  <* echo $id;*>

                  where the * is a ?
                  Register Globals = not only horrible coding habit, but now off by default in later versions of PHP (thank god).

                  PHP Code:
                  <?php
                  $id = $_GET['id'];
                  echo "$id";
                  or on one line :

                  PHP Code:
                  <?php $id = $_GET['id'];echo "$id";?>
                  Just trying to get rid of bad habits before they start growing on newbies.

                  Rory

                  Promote a site that actually retains members!

                  Comment

                  • Rory
                    Confirmed User
                    • Jul 2002
                    • 616

                    #10
                    Originally posted by psyko514
                    i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.

                    Jesus you are a fuckin mess man. Try and explain what you are doing a bit beter and I will try and help. What is id and where is it acquired. If its a JS variable you will need to do .......?id="+id+" (or whatever you called the javascript variable). I have no clue really though what you are trying to accomplish.

                    Rory

                    Promote a site that actually retains members!

                    Comment

                    • psyko514
                      See sig. Join Epic Cash.
                      • Oct 2002
                      • 22366

                      #11
                      Originally posted by magnatique
                      php has to be enabled on the server ;)

                      also, as I said, replace the * by ?


                      whatever you put in a url like
                      ?id=test

                      you call it back ('test')
                      by writing
                      <* echo $id;*>

                      where the * is a ?
                      number one, php is enabled by the server.
                      number two, i had originally tried it in the format you suggested, and that didn't work, so that's why i came here.
                      you're 100% right about java being client-side and php being server-side... i thought it would work, but it didn't

                      as for your comment rory, i'm a "newb" when it comes to javascript... not when it comes to php/c++

                      i'll attempt to explain my objective a bit better. i have a frames page, the top frame being a menu bar controlling the main frame.
                      the surfer will fill out a form in the main frame and id is a unique ID assigned to them when they sign up for my site. it's the primary key of a mysql table.
                      when the login, a script retrieves their info from the table, and ID gets plugged into a hidden form element.
                      when they fill out the form and submit it, the form gets processed and they're brought to the javascript redirect page which redirects them based on their screen size, giving them a unique page based on their screen size and ID

                      -------------------------------------------------
                      it's all moot because i've solved the problem
                      but thanks anyways

                      Bad Girl Bucks
                      - 50% Revshare through CCBill.
                      Promote BrandyDDD, Pixie's Pillows, Action Allie and more!

                      Phoenix Forum Pics | Webmaster Access Montreal pics
                      email: psyko514(a)gmail.com | icq: 214-702-014

                      Comment

                      • magnatique
                        Confirmed User
                        • Jan 2001
                        • 1830

                        #12
                        am a php newb myself, trying to learn it hehe..

                        thanks for the heads up rory, will code this way from now on ;)

                        Stunner Media Programs: StandAhead | IndieBucks | BoyCrushCash | Phoenixxx | EmoProfits | BritishBucks | HunkMoney | LatinoBucks
                        Make $$$ with Gay! Lowest Minimum Payouts in the Business, Perfect Track Record, Amazing Sites

                        Comment

                        Working...