-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuyers.php
More file actions
79 lines (71 loc) · 2.35 KB
/
buyers.php
File metadata and controls
79 lines (71 loc) · 2.35 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?
include "main.php";
include "head.php";
include "menu.php";
$resq = "SELECT user_priveleges FROM users WHERE user='".$HTTP_COOKIE_VARS["user_name"]."' AND passwd='".$HTTP_COOKIE_VARS["user_passwd"]."';";
$rc = &$db->Execute($resq);
if($rc && $rc->RecordCount() && ($rc->fields[user_priveleges]==3 || $rc->fields[user_priveleges]==2))
{
if(!$_POST[submit_user_data])
{
$resq = "SHOW TABLES FROM ".$sqlbase." LIKE 'buyers';";
$rc = &$db->Execute($resq);
if($rc->RecordCount()==0)
{
$resq = "CREATE TABLE `buyers` (`idx` INTEGER(10) AUTO_INCREMENT PRIMARY KEY,`caption` VARCHAR(50));";
if($db->Execute($resq)==false)
{
echo "Error creating tables ".$db->ErrorMsg();
}
}
$resq = "SELECT * FROM buyers;";
$rc = &$db->Execute($resq);
if($rc && $rc->RecordCount())
{
$str = "<TABLE border='1' align='center' size='100%'><tr><td><b>Íàçâàíèå</b></td><td><b>Óäàëèòü</td></b></tr>";
while($rc && !$rc->EOF)
{
$str .= "<tr><td>".$rc->fields[caption]."</b></td><td><a href='./buyers.php?cmd=rm&us_id=".$rc->fields[idx]."'> <> </a></td></tr>";
$rc->MoveNext();
}
$str .= "</TABLE>";
echo $str;
}
$myform = new HTML_Form($SELF,"POST");
$myform->addHidden("cmd","new","");
$myform->addText ("buyers_name" , "Äîáàâèòü íîâîãî","");
$myform->addSubmit("submit_user_data", "Îòïðàâèòü");
$myform->display();
}
if($_POST[submit_user_data] && $_POST[cmd]='new')
{
$resq = "SELECT * FROM buyers WHERE caption='".$_POST[buyers_name]."';";
$rc = &$db->Execute($resq);
if($rc && $rc->RecordCount())
{
echo "Òàêàÿ îðãàíèçàöèÿ óæå åñòü â áàçå";?>
<meta http-equiv="refresh" content="3; url=<?echo $SELF;?>"><?
}else
{
$resq = "INSERT INTO buyers (caption) VALUE ('".$_POST[buyers_name]."');";
if($db->Execute($resq)!=false)
{
echo "Âûïîëíåíî";
echo $_GET[cmd];
?>
<meta http-equiv="refresh" content="3; url=<?echo $SELF;?>"><?
}else "Error inserting values ".$db->ErrorMsg();
}
// echo $_POST[buyers_name];
}
if($_GET[cmd]=='rm')
{
$resq = "DELETE FROM buyers WHERE idx=".$_GET[us_id].";";
if($db->Execute($resq)!=false)
{?>
<meta http-equiv="refresh" content="0; url=<?echo $SELF;?>"><?
}else "Error deleting values ".$db->ErrorMsg();
}
}
include "foot.php";
?>