Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>insert new post</title>
- <!-- Bootstrap -->
- <link href="layout/css/bootstrap.min.css" rel="stylesheet">
- <!-- Plugins Style -->
- <link href="layout/css/style-plugins.css" rel="stylesheet">
- <!-- Font Awesome -->
- <link href="layout/css/font-awesome.min.css" rel="stylesheet">
- <!-- Style -->
- <link href="layout/css/style.css" rel="stylesheet">
- <!-- Style -->
- <link href="layout/css/admin-style.css" rel="stylesheet">
- </head>
- <body>
- <div class="container insert_post_page">
- <div class="row">
- <h2 class="text-center insert_post_title">إضافة موضوع جديد</h2>
- <form method="post" action="insert_post.php" enctype="multipart/form-data">
- <div class="form-horizontal">
- <div class="groupe-form">
- <label for="post_title" class="col-sm-2 control-label">عنوان الموضوع</label>
- <div class="col-sm-10">
- <input type="text" name="title" class="form-control" id="post_title" placeholder="عنوان الموضوع">
- </div>
- </div>
- <div class="groupe-form">
- <label for="post_author" class="col-sm-2 control-label">الكاتب</label>
- <div class="col-sm-10">
- <input type="text" name="author" class="form-control" id="post_author" placeholder="اسم الكاتب">
- </div>
- </div>
- <div class="groupe-form">
- <label for="post_keywords" class="col-sm-2 control-label">الكلمات المفتاحية</label>
- <div class="col-sm-10">
- <input type="text" name="keywords" class="form-control" id="post_keywords" placeholder="ادخل الكلمات المفتاحية">
- </div>
- </div>
- <div class="groupe-form">
- <label for="post_image" class="col-sm-2 control-label">صورة الموضوع</label>
- <div class="col-sm-10">
- <input type="file" name="image" class="form-control form-image-insert" id="post_image" placeholder="ادخل الكلمات المفتاحية">
- </div>
- </div>
- <div class="groupe-form form-content-insert">
- <label for="post_content" class="col-sm-2 control-label">نصّ الموضوع</label>
- <div class="col-sm-10">
- <textarea type="text" name="content" class="form-control" id="post_content" placeholder="أكتب نص الموضوع هنا" rows="20"></textarea>
- </div>
- </div>
- <div class="col-md-6 pull-right col-md-pull-2 form-insert-submit">
- <input type="submit" name="submit" class=" btn btn-default" value="أرسل الموضوع">
- </div>
- </div>
- </form>
- <!-- Start Zone Php isset -->
- <div class="pull-left col-sm-10 post-insert-zone-php">
- <?php
- include "../includes/connect.php";
- if (isset($_POST['submit']))
- {
- $post_title = $_POST['title'];
- $post_date = date("d-m-y",date_default_timezone_set('Africa/Algiers'));
- $post_author = $_POST['author'];
- $post_keywords = $_POST['keywords'];
- $post_content = $_POST['content'];
- $post_image = $_FILES['image']['name'];
- $image_tmp = $_FILES['image']['tmp'];
- if (empty($post_title))
- {
- echo '<div class="alert alert-danger" role="alert">الرجاء إدخال عنوان الموضوع</div>';
- }elseif(empty($post_author))
- {
- echo '<div class="alert alert-danger" role="alert">الرجاء إدخال اسم الكاتب</div>';
- }elseif(empty($post_keywords))
- {
- echo '<div class="alert alert-danger" role="alert">الرجاء إدخال الكلمات المفتاحية</div>';
- }elseif(empty($post_keywords))
- {
- echo '<div class="alert alert-danger" role="alert">الرجاء كتابة نصّ الموضوع</div>';
- }elseif(empty($post_keywords))
- {
- echo '<div class="alert alert-danger" role="alert">الرجاء اختيار صورة للموضوع</div>';
- }else{
- move_uploaded_file($image_tmp,"images/$post_image");
- $insert_query = ("$conn, 'INSERT INTO `posts`
- (`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`)'" );
- if(mysqli_query($insert_query))
- {
- echo '<div class="alert alert-success" role="alert">تمّ إرسال الموضوع بنجاح</div>';
- }
- }
- }
- ?>
- </div>
- <!-- End Zone Php isset -->
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment