Location: PHPKode > projects > WebPOS > pda/admin/newProduct.php
<?
session_start();
?><?
require_once("../../config/configDB.php");
require("../inc/yqrdb.php");
require("../inc/resizeToFile.func.php");
$mydb=new yqrdb($config_db);
if(isset($_POST["action"]))
{
	//echo "µ¥»÷µÄÌá½»°´Å¥!";
	$id_category=$_POST["id_category"];
	$id_manufacturer=$_POST["id_manufacturer"];
	$pos=$_POST["pos"];
	$title=$_POST["title"];
	$price=$_POST["price"];
	$description=$_POST["description"];
	$content=$_POST["content"];
	//---------------------------------------------------ÉÏ´«´úÂ뿪ʼ
	$iconurl=$_FILES["picture"]["name"];
	$picture=basename($iconurl);
	if(move_uploaded_file($_FILES["picture"]["tmp_name"],"./".$picture))
	{
		echo "ÉÏ´«³É¹¦!";
		$toDir="../../web/img/products";
		resizeToFile($picture,80,80,$toDir."/small/".$picture,100);
		resizeToFile($picture,120,120,$toDir."/medium/".$picture,100);
		resizeToFile($picture,500,500,$toDir."/large/".$picture,100);
		unlink($picture);
	}
	
	//---------------------------------------------------ÉÏ´«´úÂë½áÊø	
		
	$active=$_POST["active"];
	$measuring_unit=$_POST["measuring_unit"];
	$technical_details=$_POST["technical_details"];
	$sql="insert into ".$config_table["product"]." (id_category,id_manufacturer,pos,title,price,description,content,picture,active,measuring_unit,technical_details,date_created)".
	"values($id_category,$id_manufacturer,$pos,'$title',$price,'$description','$content','$picture',$active,'$measuring_unit','$technical_details',now())";
	//$sql="insert into d3_product(id_category,pos) values($id_category,$pos)";
	//echo $sql;
	//#1062 - Duplicate entry '1-' for key 2 id_manufacturerÁÐ
	$a=$mydb->executeUpdate($sql);
	if($a)
	{
		echo "²åÈëµ½Êý¾Ý¿âÖÐÁË!<br/>";
	}
	//echo "Ìá½»½áÊø!";
}
if(isset($_GET["id_category"]))
{
   $id_category=$_GET["id_category"];
}else{
   $id_category=1;
}   


$sql_ctg="select * from ".$config_table["category"]." where 1";
$arr_ctg=$mydb->executeQuery($sql_ctg);

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
<link href="../css/red_theme.css" rel="stylesheet" type="text/css" />
</head>

<body>
<? include("top_bar.php"); ?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" style="width:400px">
  <table width="347" border="0" cellpadding="3">
    <tr>
      <td width="85">Ñ¡Ôñ·ÖÀà:</td>
      <td width="244">
        <select name="id_category">
		   <? for($i=0;$i<count($arr_ctg);$i++){ 
		  	$title=$arr_ctg[$i]["title"];
		  	$id=$arr_ctg[$i]["id"];
		  	?>
          <option value="<?=$id?>" <? if($id==$id_category){?> selected<? }?>>
          <?=$title?></option>
          <? } ?>
        </select>      </td>
    </tr>
    <tr>
      <td>ÌṩÉÌ:</td>
      <td>
        <input name="id_manufacturer" type="text" value="0" />    </td>
    </tr>
    <tr>
      <td>λÖÃ:</td>
      <td>
        <input name="pos" type="text" value="0" />      </td>
    </tr>
    <tr>
      <td>±êÌâ:</td>
      <td>
        <input type="text" name="title" />      </td>
    </tr>
    <tr>
      <td>¼Û¸ñ:</td>
      <td><input type="text" name="price" value="0"/></td>
    </tr>
    <tr>
      <td>ÃèÊö:</td>
      <td>
        
        <textarea name="description" rows="5"></textarea></td>
    </tr>
    <tr>
      <td>ÄÚÈÝ:</td>
      <td>
        <textarea name="content"></textarea>      </td>
    </tr>
    <tr>
      <td>ͼƬ:</td>
      <td>
      <input type="file" name="picture" /></td>
    </tr>
    <tr>
      <td>״̬:</td>
      <td>
      <input name="active" type="radio" value="1" checked="checked" />      yes
	  <input type="radio" name="active" value="0" />
	  no	  </td>
    </tr>
    <tr>
      <td>µ¥Î»:</td>
      <td>
        <input type="text" name="measuring_unit" />      </td>
    </tr>
    <tr>
      <td>Ïêϸ:</td>
      <td height="5"><textarea name="technical_details" rows="5"></textarea></td>
    </tr>
    <tr>
      <td><input type="submit" name="Submit" value="Ìá½»" /></td>
      <td><input type="reset" name="Submit2" value="ÖØÖÃ" />
      <input type="hidden" name="action" value="create"/>
      </td>
    </tr>
  </table>
</form>
</body>
</html>
Return current item: WebPOS