-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
44 lines (29 loc) · 806 Bytes
/
functions.php
File metadata and controls
44 lines (29 loc) · 806 Bytes
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
<?php
include("connection.php");
function check_login($con) {
if(isset($_SESSION['user_id'])) {
$id = $_SESSION['user_id'];
$query = "select * from person where user_id = '$id' limit 1";
$result = mysqli_query($con,$query);
if($result && mysqli_num_rows($result) > 0) {
$user_data = mysqli_fetch_assoc($result);
// associative array
return $user_data;
}
}
return NULL;
}
// set a random number with given length
function random_num($max_length) {
$text = "";
$min_length=4;
if($max_length < 5) {
$max_length = 5;
}
$len = rand($min_length,$max_length);
for ($i=0; $i < $len; $i++) {
$text .= rand(0,9);
}
return $text;
}
//////////////////////////////////////////////////////////////////////////////////////////