HTTP POST from PHP using a link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • trpost@gmail.com

    HTTP POST from PHP using a link

    I am looking for a way to send data from one page to another as POST
    data without using forms or cURL.

    I have a php script that is passing a list of cases from on page to
    another when a link is clicked. This is working fine for the most part
    as a link, but sometimes the list gets very large and gets cut off.
    The reason it gets cut off appears to be a limitation on the amount of
    data that can be passesd in the URI.

    It looks like I can do this with cURL, but this script will run on
    several servers that do not have cURL compiled in and I do not want to
    recompile now.

    I found a few posts that say this can be done with PHP and javascript,
    but I found no good examples.

    To give you an example on what I am doing:
    <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
    $count</a>

    $allCases is a comma separated list of numbers and can get very large.
    i.e. 84638,48957,589 45,45375,....

    Thanks!
  • Rik Wasmus

    #2
    Re: HTTP POST from PHP using a link

    On Mon, 14 Jan 2008 22:57:26 +0100, <trpost@gmail.c omwrote:
    I am looking for a way to send data from one page to another as POST
    data without using forms or cURL.
    >
    I have a php script that is passing a list of cases from on page to
    another when a link is clicked. This is working fine for the most part
    as a link, but sometimes the list gets very large and gets cut off.
    The reason it gets cut off appears to be a limitation on the amount of
    data that can be passesd in the URI.
    >
    It looks like I can do this with cURL, but this script will run on
    several servers that do not have cURL compiled in and I do not want to
    recompile now.
    >
    I found a few posts that say this can be done with PHP and javascript,
    but I found no good examples.
    >
    To give you an example on what I am doing:
    <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
    $count</a>
    >
    $allCases is a comma separated list of numbers and can get very large.
    i.e. 84638,48957,589 45,45375,....
    While you could 'cheat' by firing a XMLHTTPRequest which actually posts
    with javascript, this would not be very reliable, and for about 5%-15% of
    the people just plain won't work.

    As stated numerous times the last few weeks: you probably want to save the
    data in a session. No posting/getting necessary, you allready have the
    data ready on your server.

    However: can you tell why it is your link couldn't be a button that posts
    a form? Never make it harder on yourself then should be...
    --
    Rik Wasmus

    Comment

    • Paul Lautman

      #3
      Re: HTTP POST from PHP using a link

      trpost@gmail.co m wrote:
      >I am looking for a way to send data from one page to another as POST
      data without using forms or cURL.
      >
      I have a php script that is passing a list of cases from on page to
      another when a link is clicked. This is working fine for the most part
      as a link, but sometimes the list gets very large and gets cut off.
      The reason it gets cut off appears to be a limitation on the amount of
      data that can be passesd in the URI.
      >
      It looks like I can do this with cURL, but this script will run on
      several servers that do not have cURL compiled in and I do not want to
      recompile now.
      >
      I found a few posts that say this can be done with PHP and javascript,
      but I found no good examples.
      >
      To give you an example on what I am doing:
      <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
      $count</a>
      >
      $allCases is a comma separated list of numbers and can get very large.
      i.e. 84638,48957,589 45,45375,....
      >
      Thanks!
      If you do it with php and javacript you are in effect using a form, which
      you have stated you do not want to do.


      Comment

      • Daniel Ennis

        #4
        Re: HTTP POST from PHP using a link

        trpost@gmail.co m wrote:
        I am looking for a way to send data from one page to another as POST
        data without using forms or cURL.
        >
        I have a php script that is passing a list of cases from on page to
        another when a link is clicked. This is working fine for the most part
        as a link, but sometimes the list gets very large and gets cut off.
        The reason it gets cut off appears to be a limitation on the amount of
        data that can be passesd in the URI.
        >
        It looks like I can do this with cURL, but this script will run on
        several servers that do not have cURL compiled in and I do not want to
        recompile now.
        >
        I found a few posts that say this can be done with PHP and javascript,
        but I found no good examples.
        >
        To give you an example on what I am doing:
        <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
        $count</a>
        >
        $allCases is a comma separated list of numbers and can get very large.
        i.e. 84638,48957,589 45,45375,....
        >
        Thanks!
        Your talking about cURL but also talking about doing it in links? Kinda
        confused.

        If the data is large, it should be in a database or stored in session.

        If your just wanting to submit that data to another site then display
        results, you can also use sockets and do a manual HTTP request with the
        POST data.

        The biggest question is why send so much data and not use a form?

        --
        Daniel Ennis
        faNetworks.net - Quality Web Hosting and Ventrilo Services
        System Administrator / Web Developer
        PHP Developer for 6 years
        daniel@fanetwor ks.net

        Comment

        • trpost@gmail.com

          #5
          Re: HTTP POST from PHP using a link

          On Jan 14, 3:33 pm, "Paul Lautman" <paul.laut...@b tinternet.com>
          wrote:
          trp...@gmail.co m wrote:
          I am looking for a way to send data from one page to another as POST
          data without using forms or cURL.
          >
          I have a php script that is passing a list of cases from on page to
          another when a link is clicked. This is working fine for the most part
          as a link, but sometimes the list gets very large and gets cut off.
          The reason it gets cut off appears to be a limitation on the amount of
          data that can be passesd in the URI.
          >
          It looks like I can do this with cURL, but this script will run on
          several servers that do not have cURL compiled in and I do not want to
          recompile now.
          >
          I found a few posts that say this can be done with PHP and javascript,
          but I found no good examples.
          >
          To give you an example on what I am doing:
          <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
          $count</a>
          >
          $allCases is a comma separated list of numbers and can get very large.
          i.e. 84638,48957,589 45,45375,....
          >
          Thanks!
          >
          If you do it with php and javacript you are in effect using a form, which
          you have stated you do not want to do.- Hide quoted text -
          >
          - Show quoted text -
          Well I guess I don't mind using a form, but I have a few hundred links
          on the page and didn't think it would be efficient to create a hidden
          field for each potential link. I instead just want to send the data
          that is clicked on. For example here is how you use the applciation:


          Name Low Med. High
          Test 100 980 203
          Test1 433 656 135
          Test2 118 313 733
          Test3 952 416 518
          Test4 205 813 465
          Test5 425 556 324
          Test6 113 131 943
          Test7 291 767 304
          ....


          This goes on for a few hundred rows.... You can currently click on any
          number, which passes a list of underlying numbers to another .php
          script which gives you more details. So if you click on 100, it goes
          to another script passing a comma separated list of 100 cases.


          Comment

          • Manuel Lemos

            #6
            Re: HTTP POST from PHP using a link

            Hello,

            on 01/14/2008 07:57 PM trpost@gmail.co m said the following:
            I am looking for a way to send data from one page to another as POST
            data without using forms or cURL.
            >
            I have a php script that is passing a list of cases from on page to
            another when a link is clicked. This is working fine for the most part
            as a link, but sometimes the list gets very large and gets cut off.
            The reason it gets cut off appears to be a limitation on the amount of
            data that can be passesd in the URI.
            >
            It looks like I can do this with cURL, but this script will run on
            several servers that do not have cURL compiled in and I do not want to
            recompile now.
            >
            I found a few posts that say this can be done with PHP and javascript,
            but I found no good examples.
            >
            To give you an example on what I am doing:
            <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
            $count</a>
            >
            $allCases is a comma separated list of numbers and can get very large.
            i.e. 84638,48957,589 45,45375,....
            You can try this HTTP client class. It can perform arbitrary HTTP
            requests without using Curl:




            --

            Regards,
            Manuel Lemos

            PHP professionals looking for PHP jobs


            PHP Classes - Free ready to use OOP components written in PHP
            Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials

            Comment

            • trpost@gmail.com

              #7
              Re: HTTP POST from PHP using a link

              On Jan 14, 3:55 pm, Manuel Lemos <mle...@acm.org wrote:
              Hello,
              >
              on 01/14/2008 07:57 PM trp...@gmail.co m said the following:
              >
              >
              >
              >
              >
              I am looking for a way to send data from one page to another as POST
              data without using forms or cURL.
              >
              I have a php script that is passing a list of cases from on page to
              another when a link is clicked. This is working fine for the most part
              as a link, but sometimes the list gets very large and gets cut off.
              The reason it gets cut off appears to be a limitation on the amount of
              data that can be passesd in the URI.
              >
              It looks like I can do this with cURL, but this script will run on
              several servers that do not have cURL compiled in and I do not want to
              recompile now.
              >
              I found a few posts that say this can be done with PHP and javascript,
              but I found no good examples.
              >
              To give you an example on what I am doing:
              <a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
              $count</a>
              >
              $allCases is a comma separated list of numbers and can get very large.
              i.e. 84638,48957,589 45,45375,....
              >
              You can try this HTTP client class. It can perform arbitrary HTTP
              requests without using Curl:
              >

              >
              --
              >
              Regards,
              Manuel Lemos
              >
              PHP professionals looking for PHP jobshttp://www.phpclasses. org/professionals/
              >
              PHP Classes - Free ready to use OOP components written in PHPhttp://www.phpclasses. org/- Hide quoted text -
              >
              - Show quoted text -
              I tried the Class and it looks to be able to send POST data to a page
              and request back the results. I am looking to actually goto the page
              as if you had clicked on the link. I basically created an app that
              sometimes tries to send data to a page that exceeds the max length
              allowed in the URL. What are options for getting around that limit. I
              could see using a form if I had just one link, but I have hundreds and
              can't think of a way to just send the data from the link I click on if
              I used a form.

              Comment

              • Jerry Stuckle

                #8
                Re: HTTP POST from PHP using a link

                trpost@gmail.co m wrote:
                On Jan 14, 3:55 pm, Manuel Lemos <mle...@acm.org wrote:
                >Hello,
                >>
                >on 01/14/2008 07:57 PM trp...@gmail.co m said the following:
                >>
                >>
                >>
                >>
                >>
                >>I am looking for a way to send data from one page to another as POST
                >>data without using forms or cURL.
                >>I have a php script that is passing a list of cases from on page to
                >>another when a link is clicked. This is working fine for the most part
                >>as a link, but sometimes the list gets very large and gets cut off.
                >>The reason it gets cut off appears to be a limitation on the amount of
                >>data that can be passesd in the URI.
                >>It looks like I can do this with cURL, but this script will run on
                >>several servers that do not have cURL compiled in and I do not want to
                >>recompile now.
                >>I found a few posts that say this can be done with PHP and javascript,
                >>but I found no good examples.
                >>To give you an example on what I am doing:
                >><a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
                >>$count</a>
                >>$allCases is a comma separated list of numbers and can get very large.
                >>i.e. 84638,48957,589 45,45375,....
                >You can try this HTTP client class. It can perform arbitrary HTTP
                >requests without using Curl:
                >>
                >http://www.phpclasses.org/httpclient
                >>
                >--
                >>
                >Regards,
                >Manuel Lemos
                >>
                >PHP professionals looking for PHP jobshttp://www.phpclasses. org/professionals/
                >>
                >PHP Classes - Free ready to use OOP components written in PHPhttp://www.phpclasses. org/- Hide quoted text -
                >>
                >- Show quoted text -
                >
                I tried the Class and it looks to be able to send POST data to a page
                and request back the results. I am looking to actually goto the page
                as if you had clicked on the link. I basically created an app that
                sometimes tries to send data to a page that exceeds the max length
                allowed in the URL. What are options for getting around that limit. I
                could see using a form if I had just one link, but I have hundreds and
                can't think of a way to just send the data from the link I click on if
                I used a form.
                >
                Where did the data come from in the first place? A database maybe? If
                so, just send the key back and query the database again.

                Or have a separate form for each row.


                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ==

                Comment

                • Manuel Lemos

                  #9
                  Re: HTTP POST from PHP using a link

                  Hello,

                  on 01/14/2008 11:39 PM trpost@gmail.co m said the following:
                  >>I am looking for a way to send data from one page to another as POST
                  >>data without using forms or cURL.
                  >>I have a php script that is passing a list of cases from on page to
                  >>another when a link is clicked. This is working fine for the most part
                  >>as a link, but sometimes the list gets very large and gets cut off.
                  >>The reason it gets cut off appears to be a limitation on the amount of
                  >>data that can be passesd in the URI.
                  >>It looks like I can do this with cURL, but this script will run on
                  >>several servers that do not have cURL compiled in and I do not want to
                  >>recompile now.
                  >>I found a few posts that say this can be done with PHP and javascript,
                  >>but I found no good examples.
                  >>To give you an example on what I am doing:
                  >><a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
                  >>$count</a>
                  >>$allCases is a comma separated list of numbers and can get very large.
                  >>i.e. 84638,48957,589 45,45375,....
                  >You can try this HTTP client class. It can perform arbitrary HTTP
                  >requests without using Curl:
                  >>
                  >http://www.phpclasses.org/httpclient
                  >
                  I tried the Class and it looks to be able to send POST data to a page
                  and request back the results. I am looking to actually goto the page
                  as if you had clicked on the link. I basically created an app that
                  sometimes tries to send data to a page that exceeds the max length
                  allowed in the URL. What are options for getting around that limit. I
                  could see using a form if I had just one link, but I have hundreds and
                  can't think of a way to just send the data from the link I click on if
                  I used a form.
                  I think the limit is in the browsers, something like 255 characters. So
                  I think you can submit a GET request using that class to an URL without
                  that limit.

                  --

                  Regards,
                  Manuel Lemos

                  PHP professionals looking for PHP jobs


                  PHP Classes - Free ready to use OOP components written in PHP
                  Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials

                  Comment

                  • Daniel Ennis

                    #10
                    Re: HTTP POST from PHP using a link

                    trpost@gmail.co m wrote:
                    On Jan 14, 3:55 pm, Manuel Lemos <mle...@acm.org wrote:
                    >Hello,
                    >>
                    >on 01/14/2008 07:57 PM trp...@gmail.co m said the following:
                    >>
                    >>
                    >>
                    >>
                    >>
                    >>I am looking for a way to send data from one page to another as POST
                    >>data without using forms or cURL.
                    >>I have a php script that is passing a list of cases from on page to
                    >>another when a link is clicked. This is working fine for the most part
                    >>as a link, but sometimes the list gets very large and gets cut off.
                    >>The reason it gets cut off appears to be a limitation on the amount of
                    >>data that can be passesd in the URI.
                    >>It looks like I can do this with cURL, but this script will run on
                    >>several servers that do not have cURL compiled in and I do not want to
                    >>recompile now.
                    >>I found a few posts that say this can be done with PHP and javascript,
                    >>but I found no good examples.
                    >>To give you an example on what I am doing:
                    >><a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
                    >>$count</a>
                    >>$allCases is a comma separated list of numbers and can get very large.
                    >>i.e. 84638,48957,589 45,45375,....
                    >You can try this HTTP client class. It can perform arbitrary HTTP
                    >requests without using Curl:
                    >>
                    >http://www.phpclasses.org/httpclient
                    >>
                    >--
                    >>
                    >Regards,
                    >Manuel Lemos
                    >>
                    >PHP professionals looking for PHP jobshttp://www.phpclasses. org/professionals/
                    >>
                    >PHP Classes - Free ready to use OOP components written in PHPhttp://www.phpclasses. org/- Hide quoted text -
                    >>
                    >- Show quoted text -
                    >
                    I tried the Class and it looks to be able to send POST data to a page
                    and request back the results. I am looking to actually goto the page
                    as if you had clicked on the link. I basically created an app that
                    sometimes tries to send data to a page that exceeds the max length
                    allowed in the URL. What are options for getting around that limit. I
                    could see using a form if I had just one link, but I have hundreds and
                    can't think of a way to just send the data from the link I click on if
                    I used a form.
                    Then what your asking to do is totally client side and has nothing to do
                    with PHP. Try c.l.js.

                    If its not doable in JS, then you need to use a form. But honestly what
                    your doing is very weird, and unless this is going across different
                    domains, is NOT the proper solution for what your trying to do.

                    The only reason you should ever be doing what your trying to do is if
                    your sending data from like domaina.com to domainb.com where cookies and
                    sessions wont persist.

                    If your sending this from mysite.com/page1.php to mysite.com/page2.php,
                    seriously reconsider your design of this code and change it to be passed
                    by session, database key, something to retrieve the data on the next
                    page and not send it between POST or GET.

                    --
                    Daniel Ennis
                    faNetworks.net - Quality Web Hosting and Ventrilo Services
                    System Administrator / Web Developer
                    PHP Developer for 6 years
                    daniel@fanetwor ks.net

                    Comment

                    • Michael Fesser

                      #11
                      Re: HTTP POST from PHP using a link

                      ..oO(Manuel Lemos)
                      >on 01/14/2008 11:39 PM trpost@gmail.co m said the following:
                      >>
                      >I tried the Class and it looks to be able to send POST data to a page
                      >and request back the results. I am looking to actually goto the page
                      >as if you had clicked on the link. I basically created an app that
                      >sometimes tries to send data to a page that exceeds the max length
                      >allowed in the URL. What are options for getting around that limit. I
                      >could see using a form if I had just one link, but I have hundreds and
                      >can't think of a way to just send the data from the link I click on if
                      >I used a form.
                      >
                      >I think the limit is in the browsers, something like 255 characters. So
                      >I think you can submit a GET request using that class to an URL without
                      >that limit.
                      There are also buffer limits in the web servers. For sending large
                      amounts of data to a script POST is the correct way.

                      Micha

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: HTTP POST from PHP using a link

                        Daniel Ennis wrote:
                        trpost@gmail.co m wrote:
                        >On Jan 14, 3:55 pm, Manuel Lemos <mle...@acm.org wrote:
                        >>Hello,
                        >>>
                        >>on 01/14/2008 07:57 PM trp...@gmail.co m said the following:
                        >>>
                        >>>
                        >>>
                        >>>
                        >>>
                        >>>I am looking for a way to send data from one page to another as POST
                        >>>data without using forms or cURL.
                        >>>I have a php script that is passing a list of cases from on page to
                        >>>another when a link is clicked. This is working fine for the most part
                        >>>as a link, but sometimes the list gets very large and gets cut off.
                        >>>The reason it gets cut off appears to be a limitation on the amount of
                        >>>data that can be passesd in the URI.
                        >>>It looks like I can do this with cURL, but this script will run on
                        >>>several servers that do not have cURL compiled in and I do not want to
                        >>>recompile now.
                        >>>I found a few posts that say this can be done with PHP and javascript,
                        >>>but I found no good examples.
                        >>>To give you an example on what I am doing:
                        >>><a href=case_detai ls.php?cases=". $allCases."&pri ority=Low&PG=Al l>
                        >>>$count</a>
                        >>>$allCases is a comma separated list of numbers and can get very large.
                        >>>i.e. 84638,48957,589 45,45375,....
                        >>You can try this HTTP client class. It can perform arbitrary HTTP
                        >>requests without using Curl:
                        >>>
                        >>http://www.phpclasses.org/httpclient
                        >>>
                        >>--
                        >>>
                        >>Regards,
                        >>Manuel Lemos
                        >>>
                        >>PHP professionals looking for PHP
                        >>jobshttp://www.phpclasses. org/professionals/
                        >>>
                        >>PHP Classes - Free ready to use OOP components written in
                        >>PHPhttp://www.phpclasses. org/- Hide quoted text -
                        >>>
                        >>- Show quoted text -
                        >>
                        >I tried the Class and it looks to be able to send POST data to a page
                        >and request back the results. I am looking to actually goto the page
                        >as if you had clicked on the link. I basically created an app that
                        >sometimes tries to send data to a page that exceeds the max length
                        >allowed in the URL. What are options for getting around that limit. I
                        >could see using a form if I had just one link, but I have hundreds and
                        >can't think of a way to just send the data from the link I click on if
                        >I used a form.
                        >
                        Then what your asking to do is totally client side and has nothing to do
                        with PHP. Try c.l.js.
                        >
                        If its not doable in JS, then you need to use a form. But honestly what
                        your doing is very weird, and unless this is going across different
                        domains, is NOT the proper solution for what your trying to do.
                        >
                        The only reason you should ever be doing what your trying to do is if
                        your sending data from like domaina.com to domainb.com where cookies and
                        sessions wont persist.
                        >
                        If your sending this from mysite.com/page1.php to mysite.com/page2.php,
                        seriously reconsider your design of this code and change it to be passed
                        by session, database key, something to retrieve the data on the next
                        page and not send it between POST or GET.
                        >
                        It's not good to save large amounts of data in the session - it can be
                        quite slow.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        • Michael Fesser

                          #13
                          Re: HTTP POST from PHP using a link

                          ..oO(The Natural Philosopher)
                          >Michael Fesser wrote:
                          >>
                          >There are also buffer limits in the web servers. For sending large
                          >amounts of data to a script POST is the correct way.
                          >
                          >You can do this with javascript.
                          Sure, if it doesn't have to be reliable ...

                          Micha

                          Comment

                          • The Natural Philosopher

                            #14
                            Re: HTTP POST from PHP using a link

                            Michael Fesser wrote:
                            .oO(The Natural Philosopher)
                            >
                            >Michael Fesser wrote:
                            >>There are also buffer limits in the web servers. For sending large
                            >>amounts of data to a script POST is the correct way.
                            >You can do this with javascript.
                            >
                            Sure, if it doesn't have to be reliable ...
                            >
                            Javascript is *pretty* reliable on *simple* things.

                            If the site doesn't work on I-phones, who cares ;-)

                            I don't WANT i-phone customers using my sites anyway. Spawn of the devil
                            etc.
                            Micha

                            Comment

                            Working...