You must enable CURL libraries on you system
CASE 1: Just retrieve the site content
<?php
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://www.bing.com/search?q=test&FORM=MSNH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 2: Retreive the site content by posting the value from FORM for eg. contact form and other
<?php
$a=$_POST["a"]; // Form posted value
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 3: Retrieve date from HTTPS site
<?php
$a=$_POST["a"];
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'username:password'); // IF required
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
Secure file download in PHP, Security question PHP, PHP MYSQL Interview Question -Books download - PHP solutions guidelines queries update, phpmysqlquestion
Monday, February 14, 2011
Subscribe to:
Post Comments (Atom)
security header validate
HTTP Security Headers Check Tool - Security Headers Response (serpworx.com)
-
QUESTION: 1 What is the output of the following code? echo '1' . (print '2') + 3; A. 123 B. 213 C. 142 D. 214 E. ...
-
Windows tool for creating a self-signed certificate. https://sourceforge.net/projects/portecle/ kindly install portecle tool from abov...
-
Which pillar of the AWS Well-Architected Framework recommends maintaining infrastructure as code? Operational Excellence Which of the foll...
No comments:
Post a Comment