-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
37 lines (36 loc) · 925 Bytes
/
config.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
<?php
$mysqli = new mysqli("localhost","root","","questionpaper");
// if not connected to db, show error
if ($mysqli->connect_errno)
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
session_start();
//setting cookie
function isLoggedIn()
{
if(isset($_SESSION['uid']) || isset($_COOKIE['uid']))
{ if(isset($_COOKIE['uid']))
$_SESSION['uid']=$_COOKIE['uid'];
return true;
}
else
return false;
}
// welcome message
if(isLoggedIn())
{
$uid = $_SESSION['uid'];
$string = "SELECT * FROM `users` WHERE `email`='$uid'";
$temp = $mysqli->query($string);
if($demo = $temp->fetch_assoc())
{
$full_name = $demo['fname'] . " " . $demo['lname'];
}
}
function secure($strToSecure){
global $mysqli;
$strToSecure = mysqli_real_escape_string($mysqli, $strToSecure);
$strToSecure = strip_tags($strToSecure);
$strToSecure = htmlentities($strToSecure);
return $strToSecure;
}
?>