Announcement

Collapse
No announcement yet.

Running PHP when logged in -is it possible?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Running PHP when logged in -is it possible?

    Hi All,

    We've got a feature on the site which relies on PHP. It all works perfectly until a customer logs in.

    I've read in older posts on this forum that PHP won't parse through the bbb0000x.pl perl script, but I'm just wondering if there is a solution and I just couldn't find it.

    Has anyone succesfully used PHP for logged in customers?

    Thanks! -Jc.

    here's the page: http://www.thegigrig.com/acatalog/Qu...ustom_Shop.php
    http://www.thegigrig.com/

    #2
    AFAIK perl scripts can't parse php but you can explicitly call and execute a php script from perl. See http://www.unix.com/shell-programmin...rl-script.html for some examples.

    Mike
    -----------------------------------------

    First Tackle - Fly Fishing and Game Angling

    -----------------------------------------

    Comment


      #3
      Maybe a JavaScript hack would do.

      Put this in a Layout:
      Code:
      <script type="text/javascript" src="myserverphp.php" ></script>
      And the myserverphp.php returns a lump of JavaScript source that document.writes whatever is needed on the page.

      This code should work on both html and cgi-bin pages.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks for that one, Norman -it works!

        Very crafty as well. When I first looked at it, my reaction was "That'll never work because the Javascript will execute in the browser and dump the raw PHP". But it doesn't, because the server executes the PHP before delivering it. Genius!

        It also works if you add the <script>...</script> to a fragment, so you can make it fragment-specific and not just layout specific.

        You've just opened up a whole new set of possibiilities......

        Unfortunately, however, this approach doesn't solve our problem because we are not just running the PHP once, we're interacting with it using POSTed variables. Using this method, the POST variables are not passed to the PHP served by the Javascript, but to the main page. I can't see a way to expose them to the code after the submit button is pressed.

        Anyone care to take the challenge? My brain's about to explode.
        http://www.thegigrig.com/

        Comment


          #5
          You can, of course, use:
          Code:
          <script type="text/javascript" src="myserverphp.php?myvar1=123&myvar2=456" ></script>
          Perhaps generating the entire line of code in the Actinic Perl.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #6
            Another crafty solution, but getting the POSTed variables would be a challenge beyond me.

            Hey but look what a night's troubled sleep has done:

            We were both looking at the complex route and mssing the easy one: If you want to run PHP from a fragment in a way which will work whether logged in or not, use an iframe. All the POST and GET functrionality is retained because the iframe POSTs back to itself!

            make the page's extension '.php'

            In the fragment:
            !!<
            <iframe src="yourfile.php"></iframe>
            >!!
            (you can definie width, height etc in there as well)

            and then yourfile.php is just an ordinary PHP script.

            Job Done! Tested and Working!
            http://www.thegigrig.com/

            Comment

            Working...
            X