-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletevariable.php
43 lines (43 loc) · 1.23 KB
/
deletevariable.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
40
41
42
43
<?php
require_once 'inc/util.inc';
session_start();
$_SESSION['error'] = "";
if (isset($_COOKIE['user'])) {
$username = $_COOKIE['user'];
$password = $_COOKIE['pass'];
$db_link = mysql_connect($db, $db_user, $db_pass, TRUE, MYSQL_CLIENT_INTERACTIVE);
if (!$db_link)
error(mysql_error());
mysql_query("SET NAMES utf8", $db_link);
mysql_query("SET CHARACTER SET utf8", $db_link);
mysql_query("SET SESSION interactive_timeout=30", $db_link);
mysql_select_db($dbname);
$user = mysql_query("SELECT * FROM user WHERE firstname = '$username'");
if (!$user)
error(mysql_error());
while ($userinfo = mysql_fetch_array($user)) {
if ($password != $userinfo['password']) {
header("Location: login.php");
return;
} else {
$_SESSION['unlocked'] = $userinfo['unlocked'];
if (!(bool) $_SESSION['unlocked']) {
header("Location: unlock.php");
return;
}
$id = $_GET["id"];
$userid = $userinfo['id'];
$sql = "DELETE FROM query_variable WHERE userid = '$userid' AND variableid='$id'";
$result = mysql_query($sql);
if (!$result)
error(mysql_error());
header("location: informationmodel.php#queryvariables");
}
}
mysql_free_result($user);
mysql_close($db_link);
} else {
header("Location: login.php");
return;
}
?>