Passing a $_POST reference to another page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • epots9
    Recognized Expert Top Contributor
    • May 2007
    • 1352

    Passing a $_POST reference to another page

    would it be possible to pass the contains of a $_POST reference to another page without submitting the form?

    I have a page which using $_POST to fill up some of the fields, and i have a print button that re-open the same exact page in a new window (javascript), without all the buttons, icons, etc. for a printer-friendly page, but since i'm not submitting the page the $_POST references are lost...how can i get around this?

    **i'm trying to aviod merging everything into a single string and storing it as an session.

    thanks in advance
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya epots9.

    If you use $_REQUEST instead of $_POST, you could pass the values in the URL.

    Alternatively, you could use CSS to make the printed copy pretty (specify media="print" in the LINK tag, or use a [code=css]@media print {
    body {
    color: #000000;
    }

    /* etc. */
    }[/code] rule in your stylesheet).

    Without making an AJAX call or submitting a form, though, you can't POST from the browser.

    Comment

    • mwasif
      Recognized Expert Contributor
      • Jul 2006
      • 802

      #3
      Save all the POSTed data in session like
      [PHP]$_SESSION = $_POST;[/PHP]

      May be someone else can give you a better solution.

      [The problem in this approach, it may overwrite some session data incase of same index values]

      Comment

      • epots9
        Recognized Expert Top Contributor
        • May 2007
        • 1352

        #4
        thanks for the replies, i think due to state i'm in and where i am, sessions will have to be the answer

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Originally posted by mwasif
          [PHP]$_SESSION = $_POST;[/PHP]

          [The problem in this approach, it may overwrite some session data incase of same index values]
          Use [code=php]array_merge($_S ESSION, $_POST);[/code], or [code=php]$_SESSION += array_diff_key( $_POST, $_SESSION);[/code].

          Comment

          Working...