Posting with out Submit - posted to page does nothing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • obj63
    New Member
    • Mar 2008
    • 6

    Posting with out Submit - posted to page does nothing

    Hello All,

    I am posting to a page with out a submit button using the function sendToHost - http://dodds.net/~cardinal/sendtohost.txt

    I send the following
    sendToHost('www .example.com',' post','/page.php', 'ERROR=01');
    where www.example.com is my site.

    The problem then is that page.php on the site should then read from the $_POST variable and write out the Error to the file.

    My code for page.php -

    $myFile = "testFile.t xt";
    $fh = fopen($myFile, 'w');
    fwrite($fh, $_POST['ERROR']);
    fwrite($fh, "done");
    fclose($fh);

    The problem then continues that the page.php file does not write this info out. Do you know how I would be able to get the page.php file to do this or to make sure that the post is actually being sent.

    Thanks
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by obj63
    Hello All,

    I am posting to a page with out a submit button using the function sendToHost - http://dodds.net/~cardinal/sendtohost.txt

    I send the following
    sendToHost('www .example.com',' post','/page.php', 'ERROR=01');
    where www.example.com is my site.

    The problem then is that page.php on the site should then read from the $_POST variable and write out the Error to the file.

    My code for page.php -

    $myFile = "testFile.t xt";
    $fh = fopen($myFile, 'w');
    fwrite($fh, $_POST['ERROR']);
    fwrite($fh, "done");
    fclose($fh);

    The problem then continues that the page.php file does not write this info out. Do you know how I would be able to get the page.php file to do this or to make sure that the post is actually being sent.

    Thanks
    Check if the variables are being posted actually or now.
    Write this code in the starting of the page.php[php]<?php
    echo "<pre>";
    print_r($_POST) ;
    echo "</pre>";
    ?>[/php]

    Comment

    • obj63
      New Member
      • Mar 2008
      • 6

      #3
      Thanks for the help, I was able to figure out what the issue was.
      I do have one other question though.

      So I have say page1.php that submits the underlying post to page2.php. page2.php then does what it needs to do, verifys the post submitted from page1.php and then is supposed to send a response back to page1.php.

      My question now is how do I get page1.php to read and use that response? Current code is something like this -

      page1.php -

      [PHP]sendToHost('myd omain.com','pos t','/page2.php', 'code=01&param= param'');
      sleep(5);
      //check posted response
      if($_POST['response'] != "")
      {
      // use the response given back and out put something
      }[/PHP]

      The problem is I never get the response back or the page doesn't recognize it. I did make sure that page2.php is posting back the right response by sending it to another file that outputs it to a text file so I know I am getting something back I just can't read it.

      Any ideas on how to work around this?

      Thanks again

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Is this a web project? :-?

        In this way, page1.php will never get response from page2.php. (according to me)
        Explain in detail what you want to do.

        Comment

        • obj63
          New Member
          • Mar 2008
          • 6

          #5
          The main thing that I want to do is send an internal request from one page to another. Then if that page deems everything is okay to send back to the original page so it can display a form.

          The problem is I want the original communication to be internal because I am hitting different servers. So basically it is site1.com/page1.php hits site2.com/page2.php. if the response is good from site2.com/page2.php, site1.com/page1.php needs to do something. Basically I am also trying to keep it all in the same browser session, etc. So really what I need to know how to do is once I sent the response to site2.com/page2.php - how can I get it to send something back so the original user experience can get that response internally and use it.

          If this doesn't make sense just let me know. Also if you can think of a better way of doing this with out page redirects and user input just let me know.

          Comment

          • hsriat
            Recognized Expert Top Contributor
            • Jan 2008
            • 1653

            #6
            Ok, now I got it.
            Don't use sendTohost(). With that the response won't be sent back to the same script (the one which was being executed), but will call same script again.

            Use cURL

            Regards,
            Harpreet

            Comment

            • obj63
              New Member
              • Mar 2008
              • 6

              #7
              Thanks again for the quick replies.
              I'll do some research with that and let you know how it all works.

              Joe

              Comment

              Working...