Guest User

insert post

a guest
Sep 23rd, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.70 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4.   <meta charset="utf-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1">
  7.     <title>insert new post</title>
  8.     <!-- Bootstrap -->
  9.     <link href="layout/css/bootstrap.min.css" rel="stylesheet">
  10.     <!-- Plugins Style -->
  11.     <link href="layout/css/style-plugins.css" rel="stylesheet">
  12.     <!-- Font Awesome -->
  13.     <link href="layout/css/font-awesome.min.css" rel="stylesheet">
  14.     <!-- Style -->
  15.     <link href="layout/css/style.css" rel="stylesheet">
  16.     <!-- Style -->
  17.     <link href="layout/css/admin-style.css" rel="stylesheet">
  18. </head>
  19.  
  20. <body>
  21.  
  22.     <div class="container insert_post_page">
  23.         <div class="row">
  24.  
  25.             <h2 class="text-center insert_post_title">إضافة موضوع جديد</h2>
  26.  
  27.             <form method="post" action="insert_post.php" enctype="multipart/form-data">
  28.                 <div class="form-horizontal">
  29.  
  30.                     <div class="groupe-form">
  31.                         <label for="post_title" class="col-sm-2 control-label">عنوان الموضوع</label>
  32.                         <div class="col-sm-10">
  33.                           <input type="text" name="title" class="form-control" id="post_title" placeholder="عنوان الموضوع">
  34.                         </div>
  35.                     </div>
  36.  
  37.                     <div class="groupe-form">
  38.                         <label for="post_author" class="col-sm-2 control-label">الكاتب</label>
  39.                         <div class="col-sm-10">
  40.                           <input type="text" name="author" class="form-control" id="post_author" placeholder="اسم الكاتب">
  41.                         </div>
  42.                     </div>
  43.  
  44.                     <div class="groupe-form">
  45.                         <label for="post_keywords" class="col-sm-2 control-label">الكلمات المفتاحية</label>
  46.                         <div class="col-sm-10">
  47.                           <input type="text" name="keywords" class="form-control" id="post_keywords" placeholder="ادخل الكلمات المفتاحية">
  48.                         </div>
  49.                     </div>
  50.  
  51.                     <div class="groupe-form">
  52.                         <label for="post_image" class="col-sm-2 control-label">صورة الموضوع</label>
  53.                         <div class="col-sm-10">
  54.                           <input type="file" name="image" class="form-control form-image-insert" id="post_image" placeholder="ادخل الكلمات المفتاحية">
  55.                         </div>
  56.                     </div>
  57.  
  58.                     <div class="groupe-form form-content-insert">
  59.                         <label for="post_content" class="col-sm-2 control-label">نصّ الموضوع</label>
  60.                         <div class="col-sm-10">
  61.                           <textarea type="text" name="content" class="form-control" id="post_content" placeholder="أكتب نص الموضوع هنا" rows="20"></textarea>
  62.                         </div>
  63.                     </div>
  64.  
  65.                     <div class="col-md-6 pull-right col-md-pull-2 form-insert-submit">
  66.                     <input type="submit" name="submit" class=" btn btn-default"  value="أرسل الموضوع">
  67.                     </div>
  68.  
  69.                 </div>
  70.             </form>
  71.  
  72.             <!-- Start Zone Php isset -->
  73.             <div class="pull-left col-sm-10 post-insert-zone-php">
  74.             <?php
  75.  
  76.             include "../includes/connect.php";
  77.  
  78.             if (isset($_POST['submit']))
  79.             {
  80.  
  81.                 $post_title = $_POST['title'];
  82.                 $post_date = date("d-m-y",date_default_timezone_set('Africa/Algiers'));
  83.                 $post_author = $_POST['author'];
  84.                 $post_keywords = $_POST['keywords'];
  85.                 $post_content = $_POST['content'];
  86.                 $post_image = $_FILES['image']['name'];
  87.                 $image_tmp = $_FILES['image']['tmp'];
  88.  
  89.  
  90.                 if (empty($post_title))
  91.                 {
  92.                     echo '<div class="alert alert-danger" role="alert">الرجاء إدخال عنوان الموضوع</div>';
  93.                 }elseif(empty($post_author))
  94.                 {
  95.                     echo '<div class="alert alert-danger" role="alert">الرجاء إدخال اسم الكاتب</div>';
  96.                 }elseif(empty($post_keywords))
  97.                 {
  98.                     echo '<div class="alert alert-danger" role="alert">الرجاء إدخال الكلمات المفتاحية</div>';
  99.                 }elseif(empty($post_keywords))
  100.                 {
  101.                     echo '<div class="alert alert-danger" role="alert">الرجاء كتابة نصّ الموضوع</div>';
  102.                 }elseif(empty($post_keywords))
  103.                 {
  104.                     echo '<div class="alert alert-danger" role="alert">الرجاء اختيار صورة للموضوع</div>';
  105.                 }else{
  106.                     move_uploaded_file($image_tmp,"images/$post_image");
  107.  
  108.  
  109.                 $insert_query = ("$conn, 'INSERT INTO  `posts`
  110.                (`post_title` , `post_date` , `post_author` , `post_image` , `post_keywords` , `post_content`) VALUES ( `$post_title`, `$post_date`, `$post_author`, `$post_image`, `$post_keywords`, `$post_content`)'" );
  111.  
  112.                 if(mysqli_query($insert_query))
  113.                 {
  114.                    echo '<div class="alert alert-success" role="alert">تمّ إرسال الموضوع بنجاح</div>';
  115.                 }
  116.  
  117.                 }
  118.  
  119.  
  120.  
  121.             }
  122.  
  123.             ?>
  124.             </div>
  125.             <!-- End Zone Php isset -->
  126.  
  127.         </div>
  128.     </div>
  129.  
  130. </body>
  131.  
  132. </html>
Advertisement
Add Comment
Please, Sign In to add comment