0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
admin
/
pages
/
[
Home
]
File: new_on_sale_product.php
<? include_once('FCKeditor/fckeditor.php'); if(isset($_SESSION['admin_login'])) { if($_POST['Submit']=="Insert On Sale Product Details") { $q_catalog_id="select * from catalog where catalog_name='".str_replace(" ","_",$_POST['catalog_name'])."'"; $r_catalog_id=mysql_query($q_catalog_id); $row_catalog_id=mysql_fetch_array($r_catalog_id); $catalog_id=$row_catalog_id['catalog_id']; $q_find="select * from onsale_product_details where onsale_product_name='".stripslashes($_POST['product_name'])."' and onsale_catalog_id='".$catalog_id."'"; $r_find=mysql_query($q_find); if(mysql_num_rows($r_find)==0) { if(!empty($_FILES["uploaded_file"])) { $filename2 = basename($_FILES['uploaded_file']['name']); $ext2 = strtolower(substr($filename2, strrpos($filename2, '.') + 1)); } $content=stripslashes($_POST['content']); $product_name=stripslashes($_POST['product_name']); if($_POST['image_name'] && !empty($_FILES["uploaded_file"])) { $image_name=stripslashes($_POST['image_name']).".".$ext2; } else if($_POST['image_name']=="" && !empty($_FILES["uploaded_file"])) { $image_name=$filename2; } else { $image_name="no_image.jpg"; } $image_path="catalog_images/".str_replace(" ","_",$_POST['catalog_name'])."/".$image_name; if($_POST['new_product']=="Yes") { $new_product="Y"; } else { $new_product="N"; } $q_insert="insert into onsale_product_details ( `onsale_product_id`, `onsale_catalog_id`, `onsale_product_name`, `onsale_product_main_image_path`, `onsale_product_price`, `onsale_new_product`, `onsale_product_small_description`, `onsale_product_description`, `onsale_product_weight`) values( NULL, '".$catalog_id."', '".$product_name."', '".$image_path."', '".str_replace(",","",number_format($_POST['product_price'],2))."', '".$new_product."', '".stripslashes($_POST['small_description'])."', '".$_POST['content']."', '".trim($_POST['weight'])."' )"; $r_insert=mysql_query($q_insert); if(!$r_insert) { echo mysql_error(); } //image uploading if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = strtolower(substr($filename, strrpos($filename, '.') + 1)); if ((($ext == "jpg") || ($ext == "gif") || ($ext == "JPG") || ($ext == "jpeg") || ($ext == "bmp") || ($ext == "pjpeg")) && ($_FILES["uploaded_file"]["size"] < 350000)) { //$newname = '../catimages/'.$cathead.'/'.$picnm; $newname="../".$image_path; //Check if the file with the same name is already exists on the server if (!file_exists($image_name)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $newname))) { chmod($newname, 0777); echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } //End of image uploading } else { echo "Product already exists"; } } $table_exist = 0; $sql = "show TABLES FROM $dbname"; $result = mysql_query($sql); if(!$resilt) { echo mysql_error(); } while ($row=@mysql_fetch_array($result)) { if($row[0] == 'catalog') { $table_exist = 1; } } if($table_exist == 1) { $q_catalog_list="select * from `catalog`"; $r_catalog_list=mysql_query($q_catalog_list); } ?> <link href="../css/admin-style.css" rel="stylesheet" type="text/css"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" style="padding-left:20px"><form action="" method="post" enctype="multipart/form-data" name="form1"> <table width="880" border="0" cellpadding="4" cellspacing="0" class="table-all-thin-border"> <tr> <td height="32" align="left" valign="middle" class="create-catalog-header">Insert New Product</td> </tr> <tr> <td width="390" align="left" valign="middle" class="create-catalog-text"><table width="500" border="0" cellspacing="0" cellpadding="3"> <tr> <td width="187" height="30">Select Catalog</td> <td> <select name="catalog_name" id="catalog_name"> <? while($row_catalog_list=mysql_fetch_array($r_catalog_list)) { ?> <option> <?=$row_catalog_list['catalog_name']?> </option> <? } ?> </select> </td> </tr> <tr> <td height="30">Product Name</td> <td><input name="product_name" type="text" id="product_name"></td> </tr> <tr> <td height="30">Image Name</td> <td><input name="image_name" type="text" id="image_name"></td> </tr> <tr> <td height="30">Browse Image</td> <td><input name="uploaded_file" type="file"></td> </tr> <tr> <td height="30">Product Price</td> <td><input name="product_price" type="text" id="product_price"></td> </tr> <tr> <td height="30">New Product</td> <td><input name="new_product" type="radio" value="Yes" checked> Yes <input type="radio" name="new_product" value="No"> No </td> </tr> <tr> <td height="30" align="left" valign="top">Product Small Description</td> <td align="left" valign="top"><textarea name="small_description" cols="30" rows="3" id="small_description"></textarea></td> </tr> <tr> <td height="30" align="left" valign="top">Product Weight</td> <td align="left" valign="top"><input name="weight" type="text" id="weight" size="6"> <font size="2">Unit</font> </td> </tr> </table></td> </tr> <tr> <td align="left" valign="middle" class="create-catalog-text"> </td> </tr> <tr> <td align="left" valign="middle" class="create-catalog-text"><table width="390" border="0" cellspacing="0" cellpadding="3"> <tr> <td height="32" align="left" valign="middle" class="create-catalog-header">Product Detail Description </td> </tr> </table></td> </tr> <tr> <td align="left" valign="middle" class="create-catalog-text"> <?php $sBasePath=FCKPATH; $oFCKeditor = new FCKeditor('content') ; $oFCKeditor->BasePath = $sBasePath; $oFCKeditor->Width = '100%'; $oFCKeditor->Height = '500'; $oFCKeditor->Value = $sValue; $oFCKeditor->Create(); ?> </td> </tr> <tr> <td align="center" valign="middle" class="create-catalog-text"><input type="submit" name="Submit" value="Insert On Sale Product Details"></td> </tr> </table> </form></td> </tr> </table> <? } ?>