first commit
This commit is contained in:
		
							
								
								
									
										131
									
								
								cms_admin/cn_blog_add.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								cms_admin/cn_blog_add.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,131 @@ | ||||
| <?php include('container/security.php');?> | ||||
| <!DOCTYPE html> | ||||
| <html lang="en" data-theme="light"> | ||||
|    <head> | ||||
|       <!-- head links start --> | ||||
|       <?php include 'container/head_links.php';?> | ||||
|       <!-- head links start --> | ||||
|      <script src="https://cdn.ckeditor.com/4.22.1/standard/ckeditor.js"></script> | ||||
|    </head> | ||||
|    <body> | ||||
|       <!-- side_bar start --> | ||||
|       <?php include 'container/side_bar.php' ?> | ||||
|       <!-- side_bar end --> | ||||
|       <main class="dashboard-main"> | ||||
|          <!-- Header start --> | ||||
|          <?php include 'container/header.php' ?> | ||||
|          <div class="dashboard-main-body"> | ||||
|             <div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24"> | ||||
|                <h6 class="fw-semibold mb-0">Manage AI Tool Blogs</h6> | ||||
|                <ul class="d-flex align-items-center gap-2"> | ||||
|                   <li class="fw-medium"> | ||||
|                      <a href="index-2.html" class="d-flex align-items-center gap-1 hover-text-primary"> | ||||
|                         <iconify-icon icon="solar:home-smile-angle-outline" class="icon text-lg"></iconify-icon> | ||||
|                         Dashboard | ||||
|                      </a> | ||||
|                   </li> | ||||
|                   <li>-</li> | ||||
|                   <li class="fw-medium">Add Blog</li> | ||||
|                </ul> | ||||
|             </div> | ||||
|             <div class="row gy-4"> | ||||
|                <div class="col-md-12"> | ||||
|                   <div class="card"> | ||||
|                     <div class="card-header"> | ||||
|                         <h5 class="card-title mb-0">Add New Blog</h5> | ||||
|                     </div> | ||||
|                      <div class="card-body"> | ||||
|                         <form action="" method="POST" enctype="multipart/form-data"> | ||||
|                             <div class="row gy-3"> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Blog Title</label> | ||||
|                                     <input type="text" name="title" class="form-control" required placeholder="Enter Blog Title"> | ||||
|                                 </div> | ||||
|                                 <div class="col-md-6"> | ||||
|                                     <label class="form-label">Blog Image</label> | ||||
|                                     <input type="file" name="image" class="form-control" required accept="image/*"> | ||||
|                                 </div> | ||||
|                                 <div class="col-md-6"> | ||||
|                                     <label class="form-label">Tags</label> | ||||
|                                     <input type="text" name="tags" class="form-control" required placeholder="Enter Tags"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Long Description</label> | ||||
|                                     <textarea name="editor1" id="editor1" required></textarea> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <button type="submit" class="btn btn-primary mt-3">Add Blog</button> | ||||
|                                 </div> | ||||
|                             </div> | ||||
|                         </form> | ||||
|  | ||||
|                      </div> | ||||
|                   </div> | ||||
|                </div> | ||||
|             </div> | ||||
|          </div> | ||||
|  | ||||
|         | ||||
|  | ||||
|          <?php include 'container/footer.php' ?> | ||||
|       </main> | ||||
|       <!-- Footer Links Start --> | ||||
|       <?php include 'container/footer_links.php' ?>   | ||||
|      <script> | ||||
|         // Replace textarea with CKEditor | ||||
|         CKEDITOR.replace('editor1'); | ||||
|     </script> | ||||
|     <script> | ||||
|         // Function to perform the delayed click | ||||
|         function clickNotificationClose() { | ||||
|             setTimeout(function() { | ||||
|                 var closeButton = document.querySelector('.cke_notification_close'); | ||||
|                 if (closeButton) { | ||||
|                     closeButton.click(); | ||||
|                 } else { | ||||
|                     console.log('Close button not found.'); | ||||
|                 } | ||||
|             }, 100); // Delay in milliseconds (e.g., 2000ms = 2 seconds) | ||||
|         } | ||||
|  | ||||
|         // Call the function after the page has loaded | ||||
|         window.addEventListener('load', clickNotificationClose); | ||||
|     </script> | ||||
|    </body> | ||||
| </html> | ||||
| <?php | ||||
|  | ||||
| if ($_SERVER['REQUEST_METHOD'] == 'POST') { | ||||
|  | ||||
|     // Form data | ||||
|     $title = mysqli_real_escape_string($conn, $_POST['title']); | ||||
|     $tags = mysqli_real_escape_string($conn, $_POST['tags']); | ||||
|     $description = mysqli_real_escape_string($conn, $_POST['editor1']); | ||||
|  | ||||
|     // File upload | ||||
|     $target_dir = "assets/images/blogs_image/"; | ||||
|     $file_name = basename($_FILES["image"]["name"]); | ||||
|     $file_extension = pathinfo($file_name, PATHINFO_EXTENSION); | ||||
|     $new_file_name = uniqid() . '.' . $file_extension; | ||||
|     $target_file = $target_dir . $new_file_name; | ||||
|  | ||||
|     if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { | ||||
|         // Insert data into the database | ||||
|        $query = "INSERT INTO cn_blogs (title, image, tags, description) VALUES ('$title', '$new_file_name', '$tags', '$description')"; | ||||
|         | ||||
|         if (mysqli_query($conn, $query)) { | ||||
|             echo "<script>alert('Blog added successfully.'); window.location.href = 'cn_blog_view';</script>"; | ||||
|         } else { | ||||
|             echo "<script>alert('Error: " . mysqli_error($conn) . "'); window.location.href = 'cn_blog_add';</script>"; | ||||
|         } | ||||
|     } else { | ||||
|          echo "<script>alert('Error: " . mysqli_error($conn) . "'); window.location.href = 'cn_blog_add';</script>"; | ||||
|     } | ||||
|  | ||||
|     mysqli_close($conn); | ||||
| } | ||||
| ?> | ||||
|  | ||||
|  | ||||
|  | ||||
|    | ||||
		Reference in New Issue
	
	Block a user
	 root
					root