Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
revealability
/
panel
/
admin
:
add_product.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php session_start(); include '../assets/constant/config.php'; try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?> <?php include('include/sidebar.php'); ?> <?php include('include/header.php'); ?> <div class="page-content-wrapper "> <div class="container-fluid"> <div class="row"> <div class="col-sm-12"> <div class="page-title-box"> <div class="btn-group float-right"> </div> <h4 class="page-title">Add Project</h4> </div> </div> <div class="clearfix"></div> </div> <!-- end page title end breadcrumb --> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <div class="tab-content"> <div class="tab-pane active p-3" id="home" role="tabpanel"> <form name="myform" action="app/product_crud.php" class="row" method="POST" enctype="multipart/form-data" onsubmit="return validation()" id="add_service"> <!-- <div class="form-group col-md-6"> <label class="control-label">Category<span class="text-danger">*</span></label> <select class="form-control select2" name="category_id" > <option value="">Select Category</option> </?php $stmt = $conn->prepare("SELECT * FROM `category` where delete_status= '0' "); $stmt->execute(); $record = $stmt->fetchAll(); foreach ($record as $key) { ?> <option value="</?php echo $key['id'];?>"></?php echo $key['heading']; ?></option> </?php } ?> </select> </div> --> <div class="form-group col-md-6"> <label class="control-label">Name<span class="text-danger">*</span></label> <input class="form-control" type="text" name="pro_name" required="" /> </div> <div class="form-group col-md-6"> <label class="control-label">Short Content<span class="text-danger">*</span></label> <input class="form-control" type="text" name="short_content" required="" /> </div> <div class="form-group col-md-6"> <label class="control-label">Image<span class="text-danger">*(file size must be less than 500 x 400 pixel)</span></label> <input class="form-control" type="file" name="photo"> </div> <div class="form-group col-md-6"> <label class="control-label"> Content<span class="text-danger">*</span></label> <textarea class="form-control" id="ckeditor1" type="text" name="content"></textarea> </div> <div class="form-group col-md-12"> <button class="btn btn-primary" type="submit" name="submit" onclick="addService()">Submit</button> </div> </form> </div> </div> </div> </div><!--end card--> </div><!--end col--> </div><!--end row--> </div> <!-- Page content Wrapper --> </div> <!-- content --> <?php include('include/footer.php'); ?> <script type="text/javascript"> function addService() { jQuery.validator.addMethod("alphanumeric", function(value, element) { return this.optional(element) || /^(?=.*[a-zA-Z])[a-zA-Z0-9\s!@#$%^&*()_-]+$/.test(value); }, "Please enter alphabet characters only"); jQuery.validator.addMethod("lettersonly", function(value, element) { // Check if the value is empty if (value.trim() === "") { return false; } return /^[a-zA-Z\s]*$/.test(value); }, "Please enter alphabet characters only"); $('#add_service').validate({ rules: { category_id: { required: true, }, pro_name: { required: true }, title : { required: true }, img : { required: true }, content: { required: true }, photo: { required: true, extension: "png|jpeg" } }, messages: { category_id: { required: "Select category ", pattern: "Only alphanumeric characters and spaces are allowed" }, pro_name: { required: "Please enter a product name ", pattern: "Only alphanumeric characters and spaces are allowed" }, content: { required: "Please enter a content", pattern: "Only alphanumeric characters and spaces are allowed" } } }); }; </script> <script> function validation() { var fileInput = document.getElementById('add_service').photo; var filePath = fileInput.value; var allowedExtensions = /(\.jpg|\.jpeg|\.png)$/i; if (!allowedExtensions.exec(filePath)) { alert('Invalid file type! Please upload a JPG, JPEG, or PNG image.'); fileInput.value = ''; return false; } return true; } </script> <script type="text/javascript"> $(".add-more").on('click',function(){ var html = $(".copy").html(); $(".after-add-more").before(html); // $(".after-add-more").next().find('select[name^="product_id"]').select2(); show_no(); }); $("body").on("click",".remove",function(){ $(this).parents(".control-group").remove(); show_no(); }); function show_no() { var row_cnt=0; $( ".sr_no" ).each(function() { row_cnt++; $( this ).html(row_cnt); }); } </script>