<?php
include ("../include/config.php");
?>
<html>
<head>
<title>Добави нов продукт</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<script type="text/javascript" src="../js/jquery.js" />
</head>
<body>
<script language="JavaScript">
function our(id_elem, text) {
x=document.getElementById(id_elem).value;
document.getElementById(id_elem).value = x +' '+text;
}
</script>
<form action="" method="post">
<div align="center">
Продукт:<br/>
<input name="title" type="text" class="txt" id="title" /><br/>
Категория:<br/>
<select name="cat" id="cat" style="width=270px" align="left">
<option>Изберете категория</option>
<?php
$sql = mysql_query("SELECT * FROM cats");
while($row = mysql_fetch_array($sql)){
$cat .= "<option value=\"$row[cat]\" class=\"bottom\">$row[cat]</option>";
}
echo $cat;
?>
</select><br />
Снимка:<br/>
<input name="img" type="text" id="img" /><br/>
Снимка 150x150:<br/>
<input name="simg" type="text" id="simg" /><br/>
<style>
.cena { background: url(../images/price.png) no-repeat ; background-position:top right; border: 1px solid #7f9db9; }
</style>
Цена:<br/>
<input class="cena" name="price" type="text" id="price" /> <br/>
Гаранция:<br/>
<input name="garanciq" type="text" id="garanciq" /> <br/>
Информация за продукта: <br/>
<script language="JavaScript">
function our(id_elem, text) {
x=document.getElementById(id_elem).value;
document.getElementById(id_elem).value = x +' '+text;
}
</script>
<input onclick="javascript:our('info','[b][/b]')" type='button' value='Удебелен' >
<input onclick="javascript:our('info','[i][/i]')" type='button' value='Наклонен' >
<input onclick="javascript:our('info','[u][/u]')" type='button' value='Подчертан' >
<input onclick="javascript:our('info','[s][/s]')" type='button' value='Задраскай' >
<input onclick="javascript:our('info','[new]')" type='button' value='Нов ред' >
<input onclick="javascript:our('info','*')" type='button' value='Списък' ><br />
<textarea rows="5" cols="65" name="info" type="text" id="info"> </textarea><br/>
<input name="submit" type="submit" id="submit" value="Добави" />
</div>
</form>
<div align="center">
<?php
if(isset($_POST['submit'])){
$title = $_POST['title'];
$img = $_POST['img'];
$simg = $_POST['simg'];
$price = $_POST['price'];
$info = $_POST['info'];
$garanciq= $_POST['garanciq'];
$cat = $_POST['cat'];
$sql = "INSERT INTO `produkti` (`id`, `title`, `cat`, `img`, `simg`,`price`,`info`,`garanciq`) VALUES ('NULL', '$title', '$cat', '$img', '$simg' , '$price', '$info', '$garanciq');";
$result = mysql_query($sql) or die(mysql_error());
if($result == true){
echo "Успешно добавихте новият продукт!<br />Натисне те <a href='index.php'>тук</a>, за да се върнете в Админ панела";
}}
?>
</div>
</body>
</html>