Edit file File name : discount-addf.php Content :<?php session_start(); include("../include/config.php"); include("../include/functions.php"); include("../include/simpleimage.php"); validate_admin(); if($_REQUEST['submitForm']=='yes'){ $lable=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['lable']); $slug=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['slug']); $from=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['from']); $to=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['to']); $order=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['order']); if($_REQUEST['id']==''){ $obj->query("INSERT INTO `tbl_discount_lable`(`display_label`, `discount_slug`, `discount_from`, `discount_to`, `display_order`,`status`) VALUES ('$lable' , '$slug', '$from', '$to', '$order','1')"); $_SESSION['sess_msg']='Discount added successfully'; }else{ $sql=" update tbl_discount_lable set display_label='$lable',discount_slug='$slug', discount_from='$from',discount_to='$to',display_order='$order'"; $sql.=" where id='".$_REQUEST['id']."'"; $obj->query($sql); $_SESSION['sess_msg']='Discount updated successfully'; } header("location:discount-list.php"); exit(); } if($_REQUEST['id']!=''){ $sql=$obj->query("select * from tbl_discount_lable where id=".$_REQUEST['id']); $result=$obj->fetchNextObject($sql); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo SITE_TITLE; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/admin.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript"> function validate(obj) { if(obj.name.value==''){ alert("Please enter Heading"); obj.name.focus(); return false; } if(obj.url.value==''){ alert("Please enter url"); obj.url.focus(); return false; } } </script> <script type="text/javascript"> function convertToSlug( str ) { //replace all special characters | symbols with a space str = str.replace(/%/g, "-percent-"); str = str.replace(/[`~!@#$%^&*()_\-+=\[\]{};:'"\\|\/,.<>?\s]/g, ' ').toLowerCase(); // trim spaces at start and end of string str = str.replace(/^\s+|\s+$/gm,''); // replace space with dash/hyphen str = str.replace(/\s+/g, '-'); document.getElementById("slug").value= str; //return str; } var validNumber = new RegExp(/^\d*\.?\d*$/); </script> <script type="text/javascript" src="../include/ckeditor/ckeditor.js"></script> </head> <body> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> <?php include("header.php") ?> <tr> <td align="right" class="paddRtLt70" valign="top"> <table width="99%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="middle" class="headingbg bodr text14"> <em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>Admin:<?php if($_REQUEST['id']==''){?> Add<?php } else{?>Update<?php } ?> Discount <span style="float:right; padding-right:10px;"> <input type="button" name="add" value="View Discount" class="button" onclick="location.href='discount-list.php'" /></span></td> </tr> <tr> <td height="100" align="left" valign="top" bgcolor="#f3f4f6" class="bodr"> <form name="frm" method="POST" enctype="multipart/form-data" action="" onsubmit="return validate(this)"> <input type="hidden" name="submitForm" value="yes" /> <input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" /> <table width="60%" cellpadding="0" cellspacing="0"> <tr> <td align="center" colspan="2" class="paddRt14 paddBot11"> <font color="#FF0000"><strong><?php echo $_SESSION['sess_msg']; $_SESSION['sess_msg']='';?></strong></font></td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Discount Lable:</strong></td> <td align="left" class="paddBot11"> <input type="text" name="lable" id="lable" size="150" onload="convertToSlug(this.value)" onkeyup="convertToSlug(this.value)" value="<?php echo stripslashes($result->display_label);?>" required> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Discount Slug:</strong></td> <td align="left" class="paddBot11"> <input type="text" name="slug" id="slug" size="150" value="<?php echo stripslashes($result->discount_slug);?>" required> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Discount From:</strong></td> <td align="left" class="paddBot11"> <input type="text" name="from" id="from" size="150" value="<?php echo stripslashes($result->discount_from);?>" pattern="[0-9]+([\.,][0-9]+)?" title="This should be a number." required> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Discount To:</strong></td> <td align="left" class="paddBot11"> <input type="text" name="to" id="to" size="150" value="<?php echo stripslashes($result->discount_to);?>" oninput="validateNumber(this);" title="This should be a number." pattern="[0-9]+([\.,][0-9]+)?" required> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Display order:</strong></td> <td align="left" class="paddBot11"> <input type="number" name="order" id="order" size="150" value="<?php echo stripslashes($result->display_order);?>"> </tr> <tr> <td align="right" class="paddRt14 paddBot11"> </td> <td align="left" class="paddBot11"> </td> </tr> <tr> <td width="18%" align="right" class="paddRt14 paddBot11"> </td> <td width="82%" align="left" class="paddBot11"> <input type="submit" name="submit" value="Submit" class="submit" border="0"/> <input name="Reset" type="reset" id="Reset" value="Reset" class="submit" border="0" /> </td> </tr> </table></form> </td> </tr> </table> </td> </tr> </table> </td> </tr> <?php include('footer.php'); ?> </table> </body> </html> Save