$testimonial = $_GET['testimonial'];
$name = $_GET['name'];
$url = $_GET['url'];
$date = time();
$error = false;
$err_msg = "Some errors have occured. please be sure that the form has been filled out completely.
";
if(!$name) { $error=true; }
if(!$url) { $error=true; }
if(!$testimonial) { $error=true; }
if(!$error)
{
require("mysql.php");
$conn = mysql_connect($hostname,$username,$password) or die("connect: ".mysql_error());
mysql_select_db($database) or die("select db: ".mysql_error());
$query = "insert into testimonials(name,url,testimonial,_date) values('".$name."','".$url."','".mysql_escape_string($testimonial)."','".$date."')";
$result = mysql_query($query) or die("query: ".mysql_error());
//get new data
$query = "select id,name,_date,url,testimonial from testimonials order by id desc limit 1";
$result = mysql_query($query) or die("query: ".mysql_error());
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$testimonial = $row['testimonial'];
$testimonial = preg_replace("/\r/"," ",$testimonial);
$testimonial = preg_replace("/\n/"," ",$testimonial);
$testimonial = preg_replace("/\r\n/"," ",$testimonial);
$rtrn .= '[{id:"'.$row['id'].'",name:"'.$row['name'].'",url:"'.$row['url'].'",date:"'.date("m/d/Y g:ia",$row['_date']).'",data:"'.$testimonial.'"}]';
}
echo $rtrn;
}
?>