-
Notifications
You must be signed in to change notification settings - Fork 0
/
buy.php
25 lines (25 loc) · 942 Bytes
/
buy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
session_start();
function checkSession() {
if(empty($_SESSION["admin"])) return false;
return true; }
if(!checkSession())
die("<h4>Incorrect entry</h4>");
if(empty($_POST["productname"])) die("<h4>Incorrect entry</h4>");
echo "<p align=right>";
echo "<a href=logout.php>logout</a>"; echo "</p>";
include("mysql.php");
$link=mysql_connect($host,$user,$pass);
mysql_select_db($db);
$items=$_POST["items"];
$timestamp=time(); $code=$_POST["productcode"]; $usercode=$_POST["usercode"];
$sql="select items from swimwears where code=$code"; $res=mysql_query($sql);
$row=mysql_fetch_array($res);
$nitems=$row["items"];
if($nitems<$items)
die("<h3> Ανεπαρκής Ποσότητα </h3>");
$sql="insert into order(productcode,usercode,items,timestamp) values("; $sql=$sql."$code,$usercode,$items,$timestamp)";
mysql_query($sql);
$sql="update swimwears set items=items-$items where code=$code"; mysql_query($sql);
mysql_close($link);
?>