JezK
Edit File: membershipManagement.php
<?php include("header.php"); $membershipPlans=$videocon->getplans(); if(isset($_POST['action']) && $_POST['action']=='addbusinessprice') { $addBusinessPrice=$videocon->addBusinessPrice($_POST); if($addBusinessPrice==-1){ echo "<script>alert('Given Plan Duration already exist');setTimeout(function(){ addRow();},100);</script>"; }else if($addBusinessPrice==-2){ echo "<script>alert('Given Free Plan already exist');setTimeout(function(){ addRow();},100);</script>"; } else if($addBusinessPrice==0){ echo "<script>alert('Plan adding failed');setTimeout(function(){ addRow();},100);</script>"; } else{ echo "<script>alert('Successfully added plan');window.location='membershipManagement.php'</script>"; } } ?> <section class="dashboard-counts section-padding"> <div class="container-fluid bg-white px-5 py-3"> <div class="row justify-content-end"> <a href="javascript:void(0)" class="btn btn-primary addQ mb-4" onclick="addRow()">Add Plan</a> <div class="quesContent" id="content1"></div> </div> <div class="row bg-white justify-content-center addAfter-Block"> <?php foreach($membershipPlans as $k=>$v){ ?> <div class="col-xl-2 col-sm-6 col-md-4 text-center text-white px-0 pt-3 addBlock" id="grad1"> <h1><?php echo $v['plan_price']>0?$v['plan_price']:'Free Plan';?></h1> <p class="planSize"><?php echo $v['plan_duration']>0?$v['plan_duration']." Months":'';?></p> <div class="d-flex"> <a href="planEdit.php?id=<?php echo $videocon->encrypt_decrypt('encrypt',$v['id']);?>" class="btn col-sm-6 text-white planDesign">Edit</a> <a href="#" class="btn col-sm-6 text-white topDesign">Delete</a> </div> </div> <?php } ?> </div> </div> </section> <script> function addRow () { var l= $('.d-flex').length; //length if(l>7) { alert('Sorry unable to add more than One'); return false; } if(l == '' || l == 0) { l=1; } else { l=l+1; } var testing='Q'+l; document.querySelector('#content1').insertAdjacentHTML( 'beforebegin', // '<div class="row d-flex mb-3"><input type="text" class="form-control customInput mt-4 mx-3 questionNot" id="" placeholder="Add Question" name="questionName[]"><label class="pl-3 mt-3 float-left">select type<select name="questionType[]" class="selectNot customSelectBox ml-3" onchange="onchangeVal(this.value,\''+testing+'\')" id="switch"> <option value="">Select</option><option value="1" id="t_input">Text Field</option><option value="2" id="t_textarea" >Text Area</option><option value="3" id="t_radio" >Radio Button</option><option value="4" id="t_dropdown" >Dropdown</option></select><div id='+testing+' class="dynamic_field"></div></label><a href="" class="btn default-button mt-2 " onclick="removeRow(this)">×</a></div>' // ); '<form class="form-horizontal row col-sm-12 h-100" name="businessplans" id="businessplans" method="post"><div class="container"><a href="" class="btn default-button mt-2 justify-content-end d-flex" onclick="removeRow(this)">×</a></div><div class="form-group col-xl-4"><label for="duration" class="fieldName">Enter Duration(In Months)</label><div class="row"><div class="col-sm-12"><input type="number" class="form-control formField-control" name="duration" id="duration" placeholder="Enter Duration In Months" min="1" value="<?php echo isset($_POST['duration'])?$_POST['duration']:"";?>" ></div></div></div><div class="form-group col-xl-4"><label for="price" class="fieldName">Enter Price</label><div class="row"><div class="col-sm-12"><input type="number" class="form-control formField-control" name="price" id="price" placeholder="Enter Price" min="0" value="<?php echo isset($_POST['price'])?$_POST['price']:"";?>" ></div></div></div><div class="form-group col-xl-3"><label></label><div class="row"><div class="col-sm-12"><button class="btn btn-primary w-100" name="addDom" onclick="return categoryValidate()">Add</button></div></div></div><input type="hidden" name="action" value="addbusinessprice" ></form></hr>' ); } function removeRow (input) { input.parentNode.remove() } </script> <script> function categoryValidate() { //alert($(".categoryNameValidate").val());return false; var err=0; $("span.error").remove(); if($("#duration").val()=="") { $("#duration").after('<span class="error" style="font-size:12px;color:red">Please enter Duration</span>'); err++; } if($("#price").val()=="") { $("#price").after('<span class="error" style="font-size:12px;color:red">Please enter price</span>'); err++; } /*if($(".formField-control").val()!=="") { $(".addAfter-Block").after('<div class="col-xl-2 col-sm-6 col-md-4 text-center mt-3 text-white px-0 pt-3 addBlock" id="grad1"><h1>Free Plan</h1><p class="planSize">30 Days</p><div class="d-flex"><a href="planEdit.php" class="btn col-sm-6 text-white planDesign">Edit</a><a href="planEdit.php" class="btn col-sm-6 text-white topDesign">Delete</a></div></div>'); err++; }*/ if(err) { return false;} else{ return true } } </script> <?php include("footer.php");?>