DOCTYPE html PUBLIC W3C DTD XHTML Transitional EN http www w3 org TR x

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script>tinymce.init({selector:'textarea'});</script>
<style type="text/css">
table,td ,tr {padding:0; marging:0px;}
</style>
</head>
<body>
<form action="insert_post.php" method="post" enctype="multipart/form-data">
<table width="800" align ="center" border="2">
<tr bgcolor="#FF6600">
<td colspan="6" align="center"><h1> Insert New Post:</h1> </td>
</tr>
<tr>
<td align="right" bgcolor="#FF6600"><strong>Post Title:</strong> </td>
<td><input type="text" name="post_title" size="60" /></td>
</tr>
<tr>
<td align="right" bgcolor="#FF6600"><strong>Post Category:</strong> </td>
<td>
<select name="cat">
<option value ="null">Select a Category </option>
<?php
include("include/database.php");
$get_cats="select * from categories";
$run_cats=mysql_query($get_cats);
while($cats_row=mysql_fetch_array($run_cats)){
$cat_id=$cats_row['cat_id'];
$cat_title=$cats_row['cat_title'];
echo "<option value='$cat_id'>$cat_title</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td align="right" bgcolor="#FF6600"><strong>Post Author:</strong> </td>
<td><input type="text" name="post_Author" size="60" /></td>
</tr
><tr>
<td align="right" bgcolor="#FF6600"><strong bgcolor="#FF6600">Post Keywords:</strong> </td>
<td><input type="text" name="post_keyword" size="60"/></td>
</tr>
<tr>
<td align="right" bgcolor="#FF6600"><strong>Post Image: </strong></td>
<td><input type="file" name="post_image" size="60" /></td>
</tr>
<tr>
<td align="right" bgcolor="#FF6600"><strong>Post Content: </strong></td>
<td><textarea name="post_content" rows="15" cols="40"></textarea></td>
</tr>
<tr>
<td colspan="6" bgcolor="#FF6600" align="center"><input type="Submit" name="submit" value="Publish Now"/></td>
</tr>
</form>
</body>
</html>
<?php
if(isset($_POST['submit'])){
$post_title=$_POST['post_title'];
$post_date=date('m-d-y');
$post_cat=$_POST['cat'];
$post_author=$_POST['post_author'];
$post_keywords=$_POST['post_keywords'];
$post_image=$_FILES['post_image']['name'];
$post_image_tmp=$FILE['post_image']['tmp_name'];
$post_content=$_POST['post_content'];
if($post_title=='' OR $post_cat=='null' OR $post_author=='null' OR $post_keywords=='null' OR $post_image=='null' OR $post_CONTENT ){
echo "<script>alert ('Please fill in all the fields')</script>";
exit();
}
else {
move_uploaded_file($post_image_tmp ,"news_images/post_image");
$insert_posts="insert into posts(category_id,post_title,post_date,post_author,post_keywords,post_image,post_content)values('$post_cats','$post_title','$post_date','$post_author','$post_keywords','$post_image','$post_content')";
$run_posts==mysql_query($insert_post);
if(mysql_query($run_posts)){
echo"<script>alert('post has been published')</script>";
echo"<script>window.open('insert_post.php','_self')</script>";
}
}
}
?>