/
/
home
/
u523034047
/
domains
/
commerciesconsultancy.com
/
public_html
/
admin
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.60
PHP 8.3.16
Dir:
/home/u523034047/domains/commerciesconsultancy.com/public_html/admin
Edit:
/home/u523034047/domains/commerciesconsultancy.com/public_html/admin/add-gift.php
<?php include("conn.php"); // ============ IMAGE UPLOAD FUNCTION ============ function uploadImage($fileInput){ $allowed = ['jpg','jpeg','png','webp','gif']; if($_FILES[$fileInput]['name'] == ""){ return ""; } $name = $_FILES[$fileInput]['name']; $tmp = $_FILES[$fileInput]['tmp_name']; $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); if(!in_array($ext, $allowed)){ echo "<script>alert('Only Image Files Allowed!');</script>"; return ""; } $newName = time() . "_" . rand(1000,9999) . "." . $ext; $uploadPath = "Gift_items/" . $newName; move_uploaded_file($tmp, $uploadPath); return $newName; // only filename } // ================= INSERT ==================== if(isset($_POST['add'])){ $name = mysqli_real_escape_string($connection, $_POST['name']); $desc = mysqli_real_escape_string($connection, $_POST['description']); $price = mysqli_real_escape_string($connection, $_POST['price']); // Upload Images $photo1 = uploadImage('photo1'); $photo2 = uploadImage('photo2'); $photo3 = uploadImage('photo3'); $sql = "INSERT INTO corporate_gifting(title,photo1, photo2, photo3, description, price) VALUES ('$name','$photo1', '$photo2', '$photo3', '$desc', '$price')"; if(mysqli_query($connection, $sql)){ header("Location: add-gift.php?msg=success"); exit; } else { echo mysqli_error($connection); } } // ================= DELETE ==================== if(isset($_GET['del'])){ $id = $_GET['del']; mysqli_query($connection, "DELETE FROM corporate_gifting WHERE id='$id'"); header("Location: add-gift.php?msg=deleted"); exit; } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Admin</title> <!-- BOOTSTRAP STYLES--> <link href="assets/css/bootstrap.css" rel="stylesheet" /> <!-- FONTAWESOME STYLES--> <link href="assets/css/font-awesome.css" rel="stylesheet" /> <!-- CUSTOM STYLES--> <link href="assets/css/custom.css" rel="stylesheet" /> <!-- GOOGLE FONTS--> <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' /> <link rel="stylesheet" href="richtexteditor/rte_theme_default.css" /> <script type="text/javascript" src="richtexteditor/rte.js"></script> <script type="text/javascript" src='richtexteditor/plugins/all_plugins.js'></script> </head> <body> <div id="wrapper"> <div class="navbar navbar-inverse navbar-fixed-top"> <?php include ('header.php');?> </div> <!-- /. NAV TOP --> <nav class="navbar-default navbar-side" role="navigation"> <?php include ('menu.php');?> </nav> <!-- /. NAV SIDE --> <div id="page-wrapper" > <div id="page-inner"> <h2>Add Corporate Gift</h2> <form method="POST" enctype="multipart/form-data"> <label>Enter Name</label> <input type="text" name="name" class="form-control" required> <label>Photo 1:</label><br> <input type="file" name="photo1"><br><br> <label>Photo 2:</label><br> <input type="file" name="photo2"><br><br> <label>Photo 3:</label><br> <input type="file" name="photo3"><br><br> <label>Description:</label> <textarea name="description" id="description"></textarea> <script> var editor = new RichTextEditor("#description"); </script> <br><br> <label>Price:</label> <input type="text" name="price"><br><br> <button type="submit" name="add">Add Gift</button> </form> <!-- /. ROW --> <hr /> <div class="panel panel-primary" data-collapsed="0"> <div class="panel-heading"> <div class="panel-title" > <i class="entypo-plus-circled"></i> </div> </div> <div class="panel-body"> <div style="overflow-x:auto;"> <div class="col-lg-12 col-md-12"> <div class="table-responsive"> <h2>Corporate Gifting List</h2> <table border="1" cellpadding="10" class="table"> <tr> <th>ID</th> <th>Title</th> <th>Photos</th> <th>Description</th> <th>Price</th> <th>Action</th> </tr> <?php $data = mysqli_query($connection, "SELECT * FROM corporate_gifting ORDER BY id DESC"); while($row = mysqli_fetch_array($data)){ ?> <tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['title']; ?></td> <td> <img src="Gift_items/<?php echo $row['photo1']; ?>" width="60"> <img src="Gift_items/<?php echo $row['photo2']; ?>" width="60"> <img src="Gift_items/<?php echo $row['photo3']; ?>" width="60"> </td> <td><?php echo $row['description']; ?></td> <td><?php echo $row['price']; ?></td> <td> <a href="edit-gift.php?id=<?php echo $row['id'];?>">Edit</a>| <a href="?del=<?php echo $row['id']; ?>" onclick="return confirm('Delete this item?')">Delete</a> </td> </tr> <?php } ?> </table> </table> </table> </div> </div> </div> </div> </div> </div> </div> <!-- /. PAGE INNER --> </div> <!-- /. PAGE WRAPPER --> </div> <div class="footer"> <?php include ('footer.php');?> </div> <!-- /. WRAPPER --> <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME--> <!-- JQUERY SCRIPTS --> <script src="assets/js/jquery-1.10.2.js"></script> <!-- BOOTSTRAP SCRIPTS --> <script src="assets/js/bootstrap.min.js"></script> <!-- CUSTOM SCRIPTS --> <script src="assets/js/custom.js"></script> </body> </html>
Ukuran: 6.2 KB