View file File name : precart-addf.php Content :<?php session_start(); include("../include/config.php"); include("../include/functions.php"); include("../include/simpleimage.php"); validate_admin(); $precart_title=mysqli_real_escape_string($GLOBALS['conn'],$_POST['precart_title']); $cart_amount=mysqli_real_escape_string($GLOBALS['conn'],$_POST['cart_amount']); if($_REQUEST['submitForm']=='yes'){ if($_FILES['photo']['size']>0 && $_FILES['photo']['error']==''){ $Image= new SimpleImage(); $img=time().substr($_FILES['photo']['name'],-5); move_uploaded_file($_FILES['photo']['tmp_name'],"../upload_images/precart/".$img); copy("../upload_images/precart/".$img,"../upload_images/precart/thumb/".$img); copy("../upload_images/precart/".$img,"../upload_images/precart/tiny/".$img); $Image->load("../upload_images/precart/thumb/".$img); $Image->resize(124,85); $Image->save("../upload_images/precart/thumb/".$img); $Image->load("../upload_images/precart/tiny/".$img); $Image->resize(300,300); $Image->save("../upload_images/precart/tiny/".$img); } if($_REQUEST['id']==''){ $obj->query("insert into $tbl_precart set precart_title='$precart_title',cart_amount='$cart_amount',photo='$img',posted_date=now(),status=1 "); $_SESSION['sess_msg']='Precart added sucessfully'; }else{ $sql=" update $tbl_precart set precart_title='$precart_title',cart_amount='$cart_amount' "; if($img){ $imageArr=$obj->query("select photo from $tbl_precart where id='".$_REQUEST['id']."' "); $resultImage=$obj->fetchNextObject($imageArr); @unlink("../upload_images/precart/".$resultImage->photo); @unlink("../upload_images/precart/tiny/".$resultImage->photo); @unlink("../upload_images/precart/thumb/".$resultImage->photo); $sql.=" ,photo='$img' "; } $sql.=" where id='".$_REQUEST['id']."'"; $obj->query($sql); $_SESSION['sess_msg']='Precart updated sucessfully'; } header("location:precart-list.php"); exit(); } if($_REQUEST['id']!=''){ $sql=$obj->query("select * from $tbl_precart 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.precart_title.value==''){ alert("Please enter precart title"); obj.precart_title.focus(); return false; } if(obj.cart_amount.value==''){ alert("Please enter amount"); obj.cart_amount.focus(); return false; } } </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: Add Precart <span style="float:right; padding-right:10px;"> <input type="button" name="add" value="View Precarts" class="button" onclick="location.href='precart-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="" autocomplete="off" 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"><h2> </h2></td> <td align="left" class="paddBot11"> </td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong>Precart Title:</strong></td> <td align="left" class="paddBot11"><input name="precart_title" type="text" id="precart_title" size="36" value="<?php echo stripslashes($result->precart_title);?>" /></td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong>Amount:</strong></td> <td align="left" class="paddBot11"><input name="cart_amount" type="text" id="cart_amount" size="36" value="<?php echo stripslashes($result->cart_amount);?>" /> <strong>INR</strong></td> </tr> <tr> <td align="right" class="paddBot11 paddRt14"><strong>Image:</strong></td> <td align="left" class="paddBot11"><input name="photo" type="file" /><br/> <?php if(is_file("../upload_images/precart/thumb/".$result->photo)) {?> <img src="../upload_images/precart/thumb/<?php echo $result->photo; ?>" /> <?php } ?> </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>