Using PHP Switch Statement to send form data to random URL
<p>So i am trying to wrap my head around this logic. this is code that is on a form processing script. What i want to do is send form data to one of these urls randomly. I was reading to use the switch case logic, but when i use the code you see below, it submits the form data to all 3 URLS. Is there a way so that it only sends to one of them?</p>

<pre><code>function post_to_url($url, $data) {
$fields = '';
foreach($data as $key =&gt; $value) { 
  $fields .= $key . '=' . $value . '&amp;'; 
}
rtrim($fields, '&amp;');

$post = curl_init();

curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, 1);
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);


$result = curl_exec($post);

curl_close($post);
}



return $result;

$x = rand(1,3);

switch ($x) {
    case 1:
        post_to_url("http://examplesite1.com/cgi-bin/maxuseradmin.cgi", $data2);
        break;

    case 2:
        post_to_url("http://examplesite2?fid=6646588e54", $data3);
        break;

    case 3:
        post_to_url("http://examplesite1?fid=2fb44e3888", $data4);
        break;
    }
</code></pre>

<p>the $data variables are arrays --Thanks for the help</p>
