Skip to content

Instantly share code, notes, and snippets.

@good-orbit
Created November 30, 2011 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save good-orbit/298a8625be1c5e3f78f5 to your computer and use it in GitHub Desktop.
Save good-orbit/298a8625be1c5e3f78f5 to your computer and use it in GitHub Desktop.
if(isset($_POST['subComposeBlog'])) {
$query = "SELECT COUNT(`id`) FROM `cysticBlogs` WHERE `Author` = '".$auth."' && `date` = NOW() && `status` = 'active'";
$request = mysql_query($query,$connection) or die(mysql_error());
$result = mysql_fetch_array($request);
$too_many = $result['COUNT(`id`)'];
echo $too_many;
$valid = true;
if($_POST['Category'] == "null") {
$valid = false;
$error_msgs[] = "Whoops! Please select a category for this blog.";
}
if(empty($_POST['blogTitle'])) {
$valid = false;
$error_msgs[] = "Whoops! Cannot submit a blog without a title,how are you going to attract people's attention to read your masterpiece?";
}
if(empty($_POST['blogBody'])) {
$valid = false;
$error_msgs[] = "Whoops! Cannot submit a blog without a body,that would not be a blog now would it?";
}
if($too_many > 3) {
$valid = false;
$error_msgs[] = "Whoops! Cannot submit a blog without a body,that would not be a blog now would it?";
}
if($valid) {
$query = "INSERT INTO `cysticBlogs` (
`blogTitle`,
`blogBody`,
`date`,
`time`,
`Author`,
`Category`
) VALUES (
'" . mysql_real_escape_string($_POST['blogTitle']) ."',
'" . mysql_real_escape_string($_POST['blogBody']) ."',
'" . date("Y-m-d") ."',
'" . date("G:i:s") ."',
'" . $auth->id ."',
'" . mysql_real_escape_string($_POST['Category']) ."')";
mysql_query($query, $connection) or die (mysql_error());
header("Location: BlogsSecurity.php");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment