-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
38 lines (34 loc) · 852 Bytes
/
functions.php
File metadata and controls
38 lines (34 loc) · 852 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
<?php
function check_login($con)
{
print_r($_SESSION);
if (isset($_SESSION["username"]))
{
$username = $_SESSION["username"];
$query = "select * from users where username = '$ID' limit 1";
$result = mysqli_query($con, $query);
if ($result && mysqli_num_rows($result) > 0)
{
$user_data = mysqli_fetch_assoc($result);
return $user_data;
}
}
//redirect
header("Location: signup.php");
die;
}
function hash_password($plain_pw)
{
$crypted_pw = hash('whirlpool', $plain_pw);
return ($crypted_pw);
}
function duplicate_users($con, $username)
{
$num = mysqli_num_rows(mysqli_query($con, "SELECT * FROM `users` WHERE ( `username` = '$username')"));
echo $num;
if ($num >= 1)
return (1);
else
return (0);
}
?>