<?php
if(!empty($_POST))
{
$msg=array();
if(empty($_POST['name']) || empty($_POST['condition']) || empty($_POST['qty'])|| empty($_POST['imei']) || empty($_POST['payment']) || empty($_POST['price']) )
{
$msg[]="Please full fill all requirement";
}
if(!(is_numeric($_POST['price'])))
{
$msg[]="Price must be in Numeric Format...";
}
if(!(is_numeric($_POST['imei'])))
{
$msg[]="Page must be in Numeric Format...";
}
if(!empty($msg))
{
echo '<b>Error:-</b><br>';
foreach($msg as $k)
{
echo '<li>'.$k;
}
}
else
{
$link=mysql_connect("trinix19.ipagemysql.com","fonebank","fonebank")or die("Can't Connect...");
mysql_select_db("fonebank",$link) or die("Can't Connect to Database...");
if (!isset($_FILES['image']['tmp_name'])) {
echo "";
}else{
$file=$_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name= addslashes($_FILES['image']['name']);
move_uploaded_file($_FILES["image"]["tmp_name"],"photos/" . $_FILES["image"]["name"]);
$location="photos/" . $_FILES["image"]["name"];
$b_nm=$_POST['name'];
$b_cat=$_POST['cat'];
$b_cond=$_POST['condition'];
$b_qty=$_POST['qty'];
$b_imei=$_POST['imei'];
$b_payment=$_POST['payment'];
$b_price=$_POST['price'];
$save=mysql_query("insert into product(deviceName,categoryName,condition,qty,IMEI,payment,price,image)
values('$b_nm','$b_cat','$b_cond','$b_qty','$b_imei','$b_payment',$b_price,'$location')");
header("location:products.php");
exit();
}
}
}
else
{
header("location:index.php");
}
?>