-
Notifications
You must be signed in to change notification settings - Fork 1
/
regdevice.php
39 lines (36 loc) · 1.34 KB
/
regdevice.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?
$id_device = trim(htmlspecialchars(stripslashes($_POST['id_device'])));
$name_dev = trim(htmlspecialchars(stripslashes($_POST['name_dev'])));
$version = trim(htmlspecialchars(stripslashes($_POST['ver'])));
$id_group = trim(htmlspecialchars(stripslashes($_POST['id_group'])));
$serial = trim(htmlspecialchars(stripslashes($_POST['serial'])));
$id_user = trim(htmlspecialchars(stripslashes($_POST['id_user'])));
if ( ($name_dev != '') and ($version != '') and ($id_group != '') and ($serial!='') and ($id_user!='') and ($id_device=='') )
{
include ("bd.php");
$sql = "INSERT INTO lightpoint_device (device_name,version_device,id_group_device,serial,id_user) VALUES('$name_dev',$version,$id_group,'$serial',$id_user)";
$query = mysql_query($sql);
if (!$query)
{
die('updating error: '. mysql_error());
} else
{
echo 'device created sucsessful';
}
} else
{
if ( ($name_dev != '') and ($version != '') and ($id_group != '') and ($serial!='') and ($id_user!='') and ($id_device!='') )
{
include ("bd.php");
$sql = "UPDATE lightpoint_device SET device_name='$name_dev', version_device=".$version.", id_group_device=".$id_group.", serial='$serial' WHERE id_device='$id_device'";
$query = mysql_query($sql);
if (!$query)
{
die('updating error: '. mysql_error());
} else
{
echo 'device updating sucsessful';
}
}
}
?>