<?php
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$dbname = 'database_name';
$url = 'http://example.com/post.php';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);
$query = "SELECT * FROM $dbname";
$results = mysql_query($query);
$resultsCount = mysql_numrows($results);
if($resultsCount > 0){
$randomNumber = rand(0, $resultsCount-1);
$randomTestimonial = mysql_result($results,$randomNumber,'testimonial');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'testimonial' => $randomTestimonial,
'something_else' => 'some_other_post_field'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
}else{
echo "DID NOT FIND ANYTHING";
}
?>