View file File name : faq-addf.php Content :<?php session_start(); include("../include/config.php"); include("../include/functions.php"); include("../include/simpleimage.php"); validate_admin(); $faq_cat=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['faq_cat']); $question=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['question']); $answer=mysqli_real_escape_string($GLOBALS['conn'],$_REQUEST['answer']); if($_REQUEST['submitForm']=='yes'){ if($_REQUEST['id']==''){ $obj->query("insert into $tbl_faq set faq_cat='$faq_cat',question='$question',answer='$answer',status=1 "); $_SESSION['sess_msg']='FAQ added successfully'; }else{ $sql=" update $tbl_faq set faq_cat='$faq_cat',question='$question',answer='$answer' "; $sql.=" where id='".$_REQUEST['id']."'"; $obj->query($sql); $_SESSION['sess_msg']='FAQ updated successfully'; } header("location:faq-list.php"); exit(); } if($_REQUEST['id']!=''){ $sql=$obj->query("select * from $tbl_faq 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.faq_cat.value==''){ alert("Please select related to"); obj.faq_cat.focus(); return false; } if(obj.question.value==''){ alert("Please enter question"); obj.lname.focus(); return false; } if(obj.answer.value==''){ alert("Please enter answer"); obj.answer.focus(); return false; } } </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 } ?> FAQs <span style="float:right; padding-right:10px;"> <input type="button" name="add" value="View FAQs" class="button" onclick="location.href='faq-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="100%" 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> Related To:</strong></td> <td align="left" class="paddBot11"><select name="faq_cat" style="width:240px;"> <option value="">-Select-</option> <?php $catArr=$obj->query("select * from $tbl_faqcat where status=1 order by id ",$debug=-1); while($resultCat=$obj->fetchNextObject($catArr)){ ?> <option value="<?php echo $resultCat->id; ?>"<?php if($resultCat->id==$result->faq_cat){?>selected<?php } ?>><?php echo stripslashes($resultCat->category); ?></option> <?php } ?> </select></td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Question:</strong></td> <td align="left" class="paddBot11"><textarea name="question" rows="3" cols="30" id="question" ><?php echo stripslashes($result->question);?></textarea></td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong> Answer:</strong></td> <td align="left" class="paddBot11"><textarea name="answer" rows="3" cols="30" id="answer" class="ckeditor" ><?php echo stripslashes($result->answer);?></textarea></td> </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>