D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
realadss
/
.trash
/
admin
/
Filename :
product-form.php
back
Copy
<?php include('include/header.php'); if(isset($_POST['add'])){ $category =$_POST['addcategory']; $title =$_POST['title']; $price = $_POST['price']; $desc =$_POST['desc']; $imgtitle =$_POST['imgtitle']; $imgalt =$_POST['imgalt']; $rimg1_alt =$_POST['rimg1alt']; $rimg2_alt =$_POST['rimg2alt']; $rimg3_alt =$_POST['rimg3alt']; $rimage1_title =$_POST['rimage1_title']; $rimage2_title =$_POST['rimage2_title']; $rimage3_title =$_POST['rimage3_title']; $seosyntax = $_POST['syntax']; $meta_title = $_POST['metatitle']; $meta_desc = $_POST['metadesc']; $meta_key = $_POST['metakey']; $image01 = $_FILES['image']['name']; if(!empty($image01)){ $unique = uniqid()." ".$image01; $image1 = "images/product/".$unique; $stmp_name1 = $_FILES['image']['tmp_name']; move_uploaded_file($stmp_name1, $image1); }else{ $image1=""; } $image02 = $_FILES['rimage1']['name']; if(!empty($image02)){ $unique2 = uniqid()." ".$image02; $image2 = "images/product/".$unique2; $stmp_name2 = $_FILES['rimage1']['tmp_name']; move_uploaded_file($stmp_name2, $image2); }else{ $image2=""; } $image03 = $_FILES['rimage2']['name']; if(!empty($image03)){ $unique3 = uniqid()." ".$image03; $image3 = "images/product/".$unique3; $stmp_name3 = $_FILES['rimage2']['tmp_name']; move_uploaded_file($stmp_name3, $image3); }else{ $image3=""; } $image04 = $_FILES['rimage3']['name']; if(!empty($image04)){ $unique4 = uniqid()." ".$image04; $image4 = "images/product/".$unique4; $stmp_name4 = $_FILES['rimage3']['tmp_name']; move_uploaded_file($stmp_name4, $image4); }else{ $image4=""; } // $canonicalurl = $_POST['canonicalurl']; $modifiedText0 = str_replace("&", "and", $title); $text = strtolower($modifiedText0); $desc = $_POST['desc']; $replaceArray1 = array( '"' => """, "'" => "'", ); $modifiedText1 = str_replace(array_keys($replaceArray1), array_values($replaceArray1), $desc); $slug = $_POST['slug']; $replaceArray2 = array( ' ' => "-", ); $modifiedText2 = str_replace(array_keys($replaceArray2), array_values($replaceArray2), $slug); $ans =$_POST['answer']; $que =$_POST['question']; $data= mysqli_query($conn,"insert into product (id,category,title,description,price,image,imgalt,imgtitle,rimage1,rimage2,rimage3,meta_title,meta_desc,meta_key,slug,seo_syntax,rimage1_alt,rimage2_alt,rimage3_alt,rimage1_title,rimage2_title,rimage3_title) values(' ','$category','$text','$modifiedText1','$price','$image1','$imgalt','$imgtitle','$image2','$image3','$image4','$meta_title','$meta_desc','$meta_key','$modifiedText2','$seosyntax','$rimg1_alt','$rimg2_alt','$rimg3_alt','$rimage1_title','$rimage2_title','$rimage3_title')"); if($data){ $lastid = $conn->insert_id; for($i=0; sizeof($que)>$i; $i++){ mysqli_query($conn,"insert into product_faq (product_id,question,answer) values($lastid,'".$que[$i]."','".$ans[$i]."')"); } echo "<script> alert('Product Added');window.location.href='products.php'</script>"; } else{ echo "<script> alert('Please try again')</script>"; } } ?> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <div class="container-full"> <!-- Content Header (Page header) --> <div class="content-header"> <div class="d-flex align-items-center"> <div class="me-auto"> <h4 class="page-title">Add Products</h4> </div> </div> </div> <!-- Main content --> <section class="content"> <div class="box"> <div class="box-header with-border"> <h4 class="box-title">Add New Product</h4> </div> <!-- /.box-header --> <div class="box-body"> <form role="form" method="POST" enctype="multipart/form-data"> <!-- text input --> <div class="form-group"> <label class="form-label">Meta Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="metatitle" required> </div> <div class="form-group"> <label class="form-label">Meta Description</label> <input type="text" class="form-control" placeholder="Enter ..." name="metadesc" required maxlength="180" > </div> <div class="form-group"> <label class="form-label">Meta Keywords</label> <input type="text" class="form-control" placeholder="Enter ..." name="metakey" required> </div> <div class="form-group"> <label class="form-label">Slug</label> <input type="text" class="form-control" placeholder="Enter ..." name="slug" required> </div> <div class="form-group"> <label class="form-label">SEO Syntax</label> <textarea class="form-control" name="syntax" ></textarea> </div> <div class="row"> <div class="col-6"> <div class="form-group"> <label class="form-label">Category</label> <select class="form-control" name="addcategory" required> <option>--- Select category ---</option> <?php $sql = "select * from decore_category"; $query = mysqli_query($conn, $sql); while ($row1 = mysqli_fetch_assoc($query)) { echo "<option value='".$row1['id']."'>".$row1['categoryName']."</option>"; }?> </select> </div> </div> <div class="col-6"> <div class="form-group"> <label class="form-label">Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="title" required> </div> </div> <div class="col-6"> <div class="form-group"> <label class="form-label">Price</label> <input type="text" class="form-control" placeholder="Enter ..." name="price" > </div> </div> <div class="col-6"> <div class="form-group"> <label class="form-label">Image</label> <input type="file" class="form-control" accept="image/png, image/jpeg, image/jpg" name="image" onchange="ShowImage(event)" required> <img src="" width="200" id="image" /> </div> </div> <div class="col-6"> <div class="form-group"> <label class="form-label">Image Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="imgtitle" required> </div> </div> <div class="col-6"> <div class="form-group"> <label class="form-label">Image Alt</label> <input type="text" class="form-control" placeholder="Enter ..." name="imgalt" required> </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image1 (optional)</label> <input type="file" class="form-control" accept="image/png, image/jpeg, image/jpg" name="rimage1" onchange="ShowImage2(event)" > <img src="" width="200" height="100" id="image2" /> </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image1 Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimage1_title" > </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image1 Alt</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimg1alt" > </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image2 (optional)</label> <input type="file" class="form-control" accept="image/png, image/jpeg, image/jpg" name="rimage2" onchange="ShowImage3(event)" > <img src="" width="200" height="100" id="image3" /> </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image2 Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimage2_title" > </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image2 Alt</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimg2alt" > </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image3 (optional)</label> <input type="file" class="form-control" accept="image/png, image/jpeg, image/jpg" name="rimage3" onchange="ShowImage4(event)" > <img src="" width="200" height="100" id="image4" /> </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image3 Title</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimage3_title" > </div> </div> <div class="col-4"> <div class="form-group"> <label class="form-label">Related Image3 Alt</label> <input type="text" class="form-control" placeholder="Enter ..." name="rimg3alt" > </div> </div> <div class="form-group"> <label class="form-label">FAQ</label> <div class="row"> <div class="customer_records"> <input name="question[]" type="text" placeholder="Enter Question" class="form-control" style="width:40% !important;display:inline-block;margin-bottom: 10px;"> <input name="answer[]" type="text" placeholder="Enter Answer" class="form-control" style="width:40% !important;display:inline-block;margin-bottom: 10px;"> <a class="extra-fields-customer" href="#">Add More</a> </div> <div class="customer_records_dynamic"></div> </div> </div> </div> <div class="col-12"> <div class="form-group"> <label class="form-label">Description</label> <textarea name="desc" id="editor"></textarea> </div> </div> <div class="box-footer"> <button type="submit" class="btn btn-success" name="add">Add</button> </div> </form> </div> <!-- /.box-body --> </div> </section> <!-- /.content --> </div> </div> <!-- /.content-wrapper --> <link rel="stylesheet" href="https://cdn.ckeditor.com/ckeditor5/42.0.1/ckeditor5.css"> <script type="importmap"> { "imports": { "ckeditor5": "https://cdn.ckeditor.com/ckeditor5/42.0.1/ckeditor5.js", "ckeditor5/": "https://cdn.ckeditor.com/ckeditor5/42.0.1/" } } </script> <script type="module"> import { ClassicEditor, Essentials, Paragraph, Bold, Italic, Font, Alignment, CodeBlock, Code } from 'ckeditor5'; ClassicEditor .create( document.querySelector( '#editor' ), { plugins: [ Essentials, Paragraph, Bold, Italic, Font, CodeBlock, Code, Alignment ], toolbar: [ 'undo', 'redo', '|', 'bold', 'italic', '|', 'alignment', '|', 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor','codeBlock', 'code' ] } ) .then( editor => { window.editor = editor; } ) .catch( error => { console.error( error ); } ); </script> <script> CKEDITOR.replace( 'editor'); </script> <script> CKEDITOR.replace( 'editor2'); </script> <?php include('include/footer.php') ?>