first commit
This commit is contained in:
		
							
								
								
									
										232
									
								
								cms_admin/add-basic-info.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										232
									
								
								cms_admin/add-basic-info.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,232 @@ | ||||
| <?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' ?> | ||||
| <?php | ||||
| $success = "0"; | ||||
| if (isset($_POST['submit'])) { | ||||
|     // Get the form data and sanitize inputs | ||||
|     $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); | ||||
|     $phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING); | ||||
|     $facebook = filter_var($_POST['facebook'], FILTER_SANITIZE_URL); | ||||
|     $twitter = filter_var($_POST['twitter'], FILTER_SANITIZE_URL); | ||||
|     $linked_in = filter_var($_POST['linked_in'], FILTER_SANITIZE_URL); | ||||
|     $instagram = filter_var($_POST['Instagram'], FILTER_SANITIZE_URL); | ||||
|     $youtube = filter_var($_POST['Youtube'], FILTER_SANITIZE_URL); | ||||
|     $tiktok = filter_var($_POST['Tiktok'], FILTER_SANITIZE_URL); | ||||
|     $addedby = filter_var($_POST['addedby'], FILTER_SANITIZE_STRING); | ||||
|     $m_title = filter_var($_POST['title'], FILTER_SANITIZE_STRING); | ||||
|     $m_keywords = filter_var($_POST['keywords'], FILTER_SANITIZE_STRING); | ||||
|     $m_desc = filter_var($_POST['desc'], FILTER_SANITIZE_STRING); | ||||
|  | ||||
|  | ||||
|     $m_title_CN = filter_var($_POST['title_CN'], FILTER_SANITIZE_STRING); | ||||
|     $m_keywords_CN = filter_var($_POST['keywords_CN'], FILTER_SANITIZE_STRING); | ||||
|     $m_desc_CN = filter_var($_POST['desc_CN'], FILTER_SANITIZE_STRING); | ||||
|      | ||||
|     // Check if any record exists | ||||
|     $check_query = "SELECT id FROM basic_info LIMIT 1"; | ||||
|     $result = $conn->query($check_query); | ||||
|  | ||||
|     if ($result && $result->num_rows > 0) { | ||||
|         // Record exists, update the first one | ||||
|         $row = $result->fetch_assoc(); | ||||
|         $id = $row['id']; | ||||
|         $update_query = "UPDATE basic_info SET  | ||||
|                         email = ?, phone = ?, facebook = ?, twitter = ?, linked_in = ?, instagram = ?, youtube = ?, tiktok = ?, updated_at = NOW(), m_title = ?, m_keywords = ?, m_desc = ?, m_title_CN = ?, m_keywords_CN = ?, m_desc_CN = ? | ||||
|                         WHERE id = ?"; | ||||
|         $stmt = $conn->prepare($update_query); | ||||
|         $stmt->bind_param("ssssssssssssssi", $email, $phone, $facebook, $twitter, $linked_in, $instagram, $youtube, $tiktok, $m_title, $m_keywords, $m_desc, $m_title_CN, $m_keywords_CN, $m_desc_CN,$id); | ||||
|     } else { | ||||
|         // No record exists, insert a new one | ||||
|         $insert_query = "INSERT INTO basic_info (email, phone, facebook, twitter, linked_in, instagram, youtube, tiktok, added_by, status, m_title, m_keywords, m_desc,m_title_CN, m_keywords_CN, m_desc_CN)  | ||||
|                          VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?)"; | ||||
|         $stmt = $conn->prepare($insert_query); | ||||
|         $stmt->bind_param("ssssssssissssss", $email, $phone, $facebook, $twitter, $linked_in, $instagram, $youtube, $tiktok, $addedby, $m_title, $m_keywords, $m_desc, $m_title_CN, $m_keywords_CN, $m_desc_CN); | ||||
|     } | ||||
|  | ||||
|     if ($stmt->execute()) { | ||||
|         $success = $result ? "Record updated successfully!" : "New record inserted successfully!"; | ||||
|     } else { | ||||
|         $success = "Error: " . $stmt->error; | ||||
|     } | ||||
|  | ||||
|     $stmt->close(); | ||||
|     $_POST = array(); // Clear POST data | ||||
| } | ||||
| ?> | ||||
|  | ||||
|  | ||||
|       <!-- 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 Website Basic Information</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 Website Basic Information</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 Website Basic Information</h5> | ||||
|                     </div> | ||||
|                      <div class="card-body"> | ||||
|                          <?php if ($success != "0"): ?> | ||||
|                     <div class="alert alert-success" role="alert"> | ||||
|                         <?php echo $success ?> | ||||
|                     </div> | ||||
|                 <?php endif; ?> | ||||
|                       <?php | ||||
|                         // Fetch the first available record from the 'basic_info' table | ||||
|                         $fetch_query = "SELECT * FROM basic_info LIMIT 1"; | ||||
|                         $result = $conn->query($fetch_query); | ||||
|                          | ||||
|                         // Initialize variables to empty strings if no data is found | ||||
|                       $m_desc= $m_keywords= $m_title=$email = $phone = $facebook = $twitter = $linked_in = $instagram = $youtube = $tiktok = ''; | ||||
|                          | ||||
|                         if ($result->num_rows > 0) { | ||||
|                             // Record found, populate variables | ||||
|                             $row = $result->fetch_assoc(); | ||||
|                             $email = $row['email']; | ||||
|                             $phone = $row['phone']; | ||||
|                             $facebook = $row['facebook']; | ||||
|                             $twitter = $row['twitter']; | ||||
|                             $linked_in = $row['linked_in']; | ||||
|                             $instagram = $row['instagram']; | ||||
|                             $youtube = $row['youtube']; | ||||
|                             $tiktok = $row['tiktok']; | ||||
|                              $m_title = $row['m_title']; | ||||
|                               $m_keywords = $row['m_keywords']; | ||||
|                                $m_desc = $row['m_desc']; | ||||
|                                   $m_title_CN = $row['m_title_CN']; | ||||
|                               $m_keywords_CN = $row['m_keywords_CN']; | ||||
|                                $m_desc_CN = $row['m_desc_CN']; | ||||
|                         } | ||||
|                         ?> | ||||
|                          | ||||
|                         <!-- HTML form populated with PHP data --> | ||||
|                         <form action="" method="POST" enctype="multipart/form-data"> | ||||
|                             <div class="row gy-3"> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Title EN</label> | ||||
|                                     <input type="text" name="title" class="form-control" value="<?php echo $m_title; ?>" required placeholder="title"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Keywords EN</label> | ||||
|                                     <input type="text" name="keywords" class="form-control" value="<?php echo $m_keywords; ?>" required placeholder="keyword1,keyword2,...."> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Description EN</label> | ||||
|                                     <input type="text" name="desc" class="form-control" value="<?php echo $m_desc; ?>" required placeholder="description"> | ||||
|                                 </div> | ||||
|                                  | ||||
|                                   <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Title CN</label> | ||||
|                                     <input type="text" name="title_CN" class="form-control" value="<?php echo $m_title_CN; ?>" required placeholder="title"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Keywords CN</label> | ||||
|                                     <input type="text" name="keywords_CN" class="form-control" value="<?php echo $m_keywords_CN; ?>" required placeholder="keyword1,keyword2,...."> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Meta Description CN</label> | ||||
|                                     <input type="text" name="desc_CN" class="form-control" value="<?php echo $m_desc_CN; ?>" required placeholder="description"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Email Address</label> | ||||
|                                     <input type="text" name="email" class="form-control" value="<?php echo $email; ?>" required placeholder="example@example.com"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Phone</label> | ||||
|                                     <input type="text" name="phone" class="form-control" value="<?php echo $phone; ?>" required placeholder="Phone"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Facebook</label> | ||||
|                                     <input type="text" name="facebook" class="form-control" value="<?php echo $facebook; ?>" required placeholder="https://www.facebook.com/example"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Twitter</label> | ||||
|                                     <input type="text" name="twitter" class="form-control" value="<?php echo $twitter; ?>" required placeholder="https://www.twitter.com/example"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Linked In</label> | ||||
|                                     <input type="text" name="linked_in" class="form-control" value="<?php echo $linked_in; ?>" required placeholder="https://www.linkedin.com/example"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Instagram</label> | ||||
|                                     <input type="text" name="Instagram" class="form-control" value="<?php echo $instagram; ?>" required placeholder="https://www.instagram.com/example"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Youtube</label> | ||||
|                                     <input type="text" name="Youtube" class="form-control" value="<?php echo $youtube; ?>" required placeholder="https://www.youtube.com/example"> | ||||
|                                 </div> | ||||
|                                 <div class="col-12"> | ||||
|                                     <label class="form-label">Tiktok</label> | ||||
|                                     <input type="text" name="Tiktok" class="form-control" value="<?php echo $tiktok; ?>" required placeholder="https://www.tiktok.com/example"> | ||||
|                                 </div> | ||||
|                                 <input type="hidden" value="<?php echo $_SESSION['user_id']; ?>" name="addedby"> | ||||
|                                 <div class="col-12"> | ||||
|                                     <button type="submit" name="submit" class="btn btn-primary mt-3">Submit</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> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|    | ||||
		Reference in New Issue
	
	Block a user
	 root
					root