SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist runeveryday's Avatar
    Join Date
    Jul 2009
    Posts
    437
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to receieve the value from php curl transverse data?

    0 down vote favorite


    Now i want to transverse POST data in a.com/a.php to b.com/b.php.suppose a.php has a form.

    HTML Code:
    <form method="post" action="">
    name: <input type="text" name="name" /><br />
    email: <input type="text" name="email" />
    </form>
    the following is my code php code part in a.php. how to receieve the transversed data in b.com/b.php
    HTML Code:
        $url = 'http://www.b.com/b.php';
        $fields = array(
        'username' => addslashes($_POST['name']),
        'email' => addslashes($_POST['email']),
         'ip' => $_SERVER['REMOTE_ADDR']
    );
    
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, true);
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
    $result = curl_exec($ch);
     curl_close($ch);
    how to write the form action part? is there something wrong with my code? thank you.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    a.php's form indicates that it will be sending the data to a.php, not b.php.

    Action="" is translated by browsers as "Send this to myself."

    If you're using a.php to curl the postvalues to b.php, then b.php should be constructed as if it were the normal receiver (get fields out of $_POST, etc).
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Are a.com and b.com on the same machine?

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2011
    Location
    Portland
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    serialize your $fields array.
    coming soon sitejuju.com my new development portfolio


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •