Home » PHP » Requested data using cURL

Requested data using cURL

cURL is a popular method for getting data from different servers and different protocols. Today i am going to show you how to use cURL simply to play with a small amount of data and saving the data in the database.

Suppose you have a form where you are generating some value and you need those values to convert into URL, send the data using cURL, getting the status of that page and at last saving the data in the database.

step 1:

grab the form data using request method, filter ( note that: you have to create your own filter method ) it and make it a URL by following method:

$_REQUEST = filter( $_REQUEST );
$values = array_values( $_REQUEST );


step 2:

Now you have the values. You have to convert it into url. Let’s do it.

$get_url = http_build_query( $_REQUEST, '', '&' );
 $get_url = str_replace( '+', '', $get_url );


step 3:

Now you have the URL in your hand. You just have to send the data in the server by cURL and have to get the page status. For doing that follow the code.

$get_curl_url = 'http://www.someurl.com/page/?'.$get_url;
 $get_status = get_url_status( $get_url );
 $get_status = strip_tags( $get_status );


Step 4:

If everything is alright then you have the data and status in your hand. Now it’s time to save the data in the database. Connect with your desired database ( I hope you are that smart to do that ) and push the data into the database and you are done. You also can send the data through email through php mail function ( I have used my own function using PHPMailer ).

$ExplodeKeywords = implode('","', $values);
 $query = 'INSERT INTO '.$tablename.' ('.$tablecolumn.') VALUES ("'.$ExplodeKeywords.'","'.$get_status.'")';

//for sending mail

echo sendMail( $_REQUEST['Email'], $get_curl_url, $get_status );


Hope this helped you, Thanks.


I picked PHP and JavaScript as a career start-up and developed a lot of applications using these. Like Management Application, Web Scrapping, Web API, E-Commerce Solutions, Finance Application etc. Outside of my professional life, I also do projects and code for reputation and my personal portfolio.

Leave a Reply

Your email address will not be published. Required fields are marked *