File manager - Edit - /home/custbahd/irungikitchen.com/admin/table/add.php
Back
<?php //including the database connection file include_once("config.php"); $msg = ""; if(isset($_POST['Submit'])) { $name = mysqli_real_escape_string($mysqli, $_POST['name']); $cat = mysqli_real_escape_string($mysqli, $_POST['cat']); $type = mysqli_real_escape_string($mysqli, $_POST['type']); $gender = mysqli_real_escape_string($mysqli, $_POST['gender']); $size = mysqli_real_escape_string($mysqli, $_POST['size']); $package = mysqli_real_escape_string($mysqli, $_POST['package']); $price = mysqli_real_escape_string($mysqli, $_POST['price']); $image = mysqli_real_escape_string($mysqli, $_FILES['image']['name']); $target = "images/".basename($_FILES['image']['name']); // checking empty fields if(empty($name) || empty($cat)|| empty($type) || empty($gender) || empty($package) || empty($price) || empty($image)) { if(empty($name)) { echo "<font color='red'>Name field is empty.</font><br/>"; } if(empty($cat)) { echo "<font color='red'>Category field is empty.</font><br/>"; } if(empty($type)) { echo "<font color='red'>Type field is empty.</font><br/>"; } if(empty($gender)) { echo "<font color='red'>Gender field is empty.</font><br/>"; } if(empty($package)) { echo "<font color='red'>Package field is empty.</font><br/>"; } if(empty($price)) { echo "<font color='red'>Price field is empty.</font><br/>"; } if(empty($image)) { echo "<font color='red'>Image not selected.</font><br/>"; } //link to the previous page echo "<br/><a href='javascript:self.history.back();'>Go Back</a>"; } else { // if all the fields are filled (not empty) //insert data to database $result = mysqli_query($mysqli, "INSERT INTO shop(name,cat,type,gender,size,package,price,image) VALUES('$name','$cat','$type','$gender','$size','$package','$price','$image')"); if (move_uploaded_file($_FILES['image']['tmp_name'], $target)); //display success message echo "<font color='green'>Data added successfully."; echo "<br/><a href='index.php'>View Result</a>"; } } ?> <html> <head> <title>Add Product</title> </head> <body> <a href="index.php">Home</a> <br/><br/> <form action="add.php" method="post" name="form1" enctype="multipart/form-data"> <table width="50%" border="0"> <tr> <td>Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Category</td> <td> <select name="cat" id="category" class="form-control" required> <option value="Null" readonly>Select</option> <option value="1">Clothings</option> <option value="2">Baby Wear</option> <option value="3">Boy's Outfits</option> <option value="4">Girl's Outfits</option> <option value="5">Sleep & Under Wear</option> <option value="6">Gear | Accessories</option> <option value="7">Baby Health Care</option> <option value="8">Baithing & Toiletries</option> <option value="9">Changing</option> <option value="10">Accessories</option> <option value="11">Feeding</option> <option value="12">Mom Neccessities</option> </td> </tr> <tr> <td>Type</td> <td> <select name="type" id="type" class="form-control" required> <option value="Null" readonly>Select</option> <option value="1">Kids</option> <option value="2">Adults</option> </td> </tr> <tr> <td>Gender</td> <td> <input type="radio" name="gender" value="1"> Male <input type="radio" name="gender" value="2"> Female </td> </tr> <tr> <td>Size</td> <td> <input type="radio" name="size" value="1"> Small <input type="radio" name="size" value="2"> Medium <input type="radio" name="size" value="3"> Large <input type="radio" name="size" value="4"> XL <input type="radio" name="size" value="5"> XXL </td> </tr> <tr> <td>Package</td> <td> <select name="package" id="package" class="form-control" required> <option value="Null" readonly>Select</option> <option value="1">Single</option> <option value="2">Double</option> <option value="3">3 Items</option> <option value="4">4 Items</option> <option value="5">5 Items</option> </td> </tr> <tr> <td>Price</td> <td><input type="text" name="price"></td> </tr> <tr> <td>Image</td> <td><input type="file" name="image"></td> </tr> <tr> <td></td> <td><input type="submit" name="Submit" value="Add"></td> </tr> </table> </form> </body> </html>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 1.8 |
proxy
|
phpinfo
|
Settings