Hi I tries PHP Post Request inside a POST Request thinking it might be useful to me and my code is given below
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
form the index.php file and index2.php is another file in the same directory and when i open the page i get the following error in my error.log file
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
What i want to do is I have a reservation form that send post request and then i want to process post values and send again post request to paypal
function curl_int(); cause server error,install sudo apt-get install php5-curl restart apache2 server .. it will work like charm
Just install the last version of wamp server.
Just adding my answer for the case where there are multiple versions of PHP installed in your system, and you are sure that you have already installed the
php-curl
package, and yet Apache is still giving you the same error.curl_init() undefined even if php-curl is enabled in Php 7.
For Windows, if anybody is interested, uncomment the following line (by removing the ;) from php.ini
Restart apache server.
(Trying to get Curl working via PHP and Apache on Windows...)
I kept getting an error saying: Call to undefined function 'curl_init()'
I made sure I had enabled curl with this line in my php.ini file: extension=php_curl.dll
I made sure the extension_dir variable was being set properly, like this: extension_dir = "ext"
I was doing everything everyone else said on the forums and curl was not showing up in my call to phpinfo(), and I kept getting that same error from above.
Finally I found out that Apache by default looks for php.ini in the C:\Windows folder. I had been changing php.ini in my PHP installation folder. Once I copied my php.ini into C:\Windows, everything worked.
Took me forever to figure that out, so thought I'd post in case it helps someone else.
RusAlex answer is right in that for Apache you have to install and enable curl and restart your apache service:
On my Ubuntu Server with nginx and php5-fpm I however ran into the following problem. I had to restart nginx and php5-fpm like so:
But I had non-working php5-fpm processes hanging around, which apparently is a bug in ubuntu https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376 So I had to kill all idle php5-fpm processes to able to restart php5-fpm so that the curl module is actually loaded