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?
function post_to_url($url, $data) {
$fields = '';
foreach($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$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;
}
the $data variables are arrays --Thanks for the help