Posted By

kumar_sekhar on 04/14/11


Tagged

form curl post


Versions (?)

Form Post using CURL in php


 / Published in: PHP
 

Simply define your POSTURL and POSTVARS in name = value string format. It will post the form.

  1. <?php
  2. define('POSTURL', 'http://youdomain.nl/filename.php');
  3. define('POSTVARS', 'Aanhef=Mr&Voorletters=testVoorletters&Tussenvoegsel=tetsTussenvoegsel&Achternaam=testfname&Adres=111,ddd,NL&Huisnr=sfsfs&Huisnr_toevoeging=ggggg&Postcode=324234&Email=[email protected]&dealer_id=111'); // POST VARIABLES TO BE SENT
  4.  
  5.  
  6. // INITIALIZE ALL VARS
  7. $Email='';
  8. $ch='';
  9. $Rec_Data='';
  10. $Temp_Output='';
  11.  
  12. if($_SERVER['REQUEST_METHOD']==='POST') { // REQUIRE POST OR DIE
  13. if(isset($_POST['Email'])) $Email=$_POST['Email']; // GET EMAIL INTO VAR
  14.  
  15. $ch = curl_init(POSTURL);
  16. curl_setopt($ch, CURLOPT_POST ,1);
  17. curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVARS.$Email);
  18. // curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
  19. curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS
  20. curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
  21. $Rec_Data = curl_exec($ch);
  22.  
  23. header("Content-Type: text/html");
  24. $Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
  25. $Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output));
  26. $Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output);
  27. $Temp_Output = substr($Temp_Output,307,200);
  28. echo $Temp_Output;
  29. $Final_Out=ob_get_clean();
  30. echo $Final_Out;
  31. curl_close($ch);
  32. } else die('Hacking attempt Logged!');
  33.  

Report this snippet  

You need to login to post a comment.