forked from Lydraine/PsYchoPiQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
90 lines (84 loc) · 3.28 KB
/
functions.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
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
80
81
82
83
84
85
86
87
88
89
90
<?php
function insert($peg, $hole) {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{$DATABASE_NAME}");
$book_note = mysqli_query($book_open,
"INSERT INTO {$DATABASE_TABLE} ({$hole}) VALUES('{$peg}')");
$book_close = mysqli_close($book_open);
}
function sel_read($dbase, $table, $entry, $criteria, $value, $note) {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{${$dbase}}");
$skim = mysqli_query($book_open,
"SELECT {$entry} FROM {${$table}} WHERE {$criteria} = '{$value}';");
while($scan = mysqli_fetch_array($skim)) {
global ${$note};
${$note} = $scan;
}
$book_close = mysqli_close($book_open);
}
function db_conn() {
}
function enter_user() {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{$DATABASE_NAME}");
$book_note = mysqli_query($book_open,
"INSERT INTO {$DATABASE_TABLE} (name, email) VALUES('{$_POST['name']}', '{$_POST['email']}')");
$book_close = mysqli_close($book_open);
}
function update_attempts() {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{$DATABASE_NAME}");
$skim = mysqli_query($book_open,
"SELECT attempts FROM {$DATABASE_TABLE} WHERE email = '{$_SESSION['email']}';");
while($scan = mysqli_fetch_array($skim)) {
$attempts = $scan[0];
$attempts++;
}
$book_note = mysqli_query($book_open,
"UPDATE {$DATABASE_TABLE} SET attempts = {$attempts} WHERE email = '{$_SESSION['email']}';");
$book_close = mysqli_close($book_open);
}
function update_tries() {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{$DATABASE_NAME}");
$skim = mysqli_query($book_open,
"SELECT tries FROM {$DATABASE_TABLE} WHERE email = '{$_SESSION['email']}';");
while($scan = mysqli_fetch_array($skim)) {
$tries = $scan[0];
$cur_tries = $_SESSION['tries'];
}
if($cur_tries < $tries OR !is_numeric($tries)){
$book_note = mysqli_query($book_open,
"UPDATE {$DATABASE_TABLE} SET tries = {$_SESSION['tries']} WHERE email = '{$_SESSION['email']}';");
}
$book_close = mysqli_close($book_open);
}
function update_plays() {
include('config.php');
$book_open = mysqli_connect($SERVER_HOSTNAME, $SQL_USERNAME, $SQL_PASSWORD);
$book_chapter = mysqli_select_db($book_open, "{$DATABASE_NAME}");
$skim = mysqli_query($book_open,
"SELECT plays FROM {$DATABASE_TABLE} WHERE email = '{$_SESSION['email']}';");
while($scan = mysqli_fetch_array($skim)) {
$plays = $scan[0];
$plays++;
}
$book_note = mysqli_query($book_open,
"UPDATE {$DATABASE_TABLE} SET plays = {$plays} WHERE email = '{$_SESSION['email']}';");
$book_close = mysqli_close($book_open);
}
function persist() {
if (isset($_SESSION['email']) AND !isset($_SESSION['welcome'])) {
$_SESSION['welcome'] = true;
}
if (isset($_SESSION['email']) AND !isset($_SESSION['number'])) {
$_SESSION['number'] = rand(1, 100);
}
}
?>