title: Set cURL address via POST variable
body: <p>I have been trying to use cURL in PHP with a dynamic address (i.e. set via a POST variable) but it isn't working!</p>
  
  <pre><code>&lt;?php
  $address = $_POST['address'];
  
  //echo $address;
  //$address = "http://twitter.com";
  
  $curl_handle=curl_init();
  curl_setopt($curl_handle,CURLOPT_URL, $address);
  curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
  curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
  $buffer = curl_exec($curl_handle);
  curl_close($curl_handle);
  
  if (empty($buffer)) {
      echo "Sorry, ".$address." are a bunch of poopy-heads.&lt;p&gt;";
  }
  else {
      echo $buffer;
  }
  ?&gt;
  </code></pre>
  
  <p>I know the POST is working, because I can echo the $address variable and see the contents of $address that I sent.</p>