-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbconnect.php
39 lines (30 loc) · 988 Bytes
/
dbconnect.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
<?php
if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"){
$redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
// this will avoid mysql_connect() deprecation error.
error_reporting(E_ALL);
ini_set("display_error",1);
session_start();
define('DBHOST', 'localhost');
define('DBUSER', 'noit1_visitme');
define('DBPASS', 'noit1_visitme');
define('DBNAME', 'noit1_visitme_db');
$conn = @mysqli_connect(DBHOST,DBUSER,DBPASS);
$dbcon = mysqli_select_db($conn, DBNAME);
mysqli_query($conn, "SET NAMES'utf8'");
if ( !$conn ) {
die("Connection failed : " . mysqli_error());
}
if ( !$dbcon ) {
die("Database Connection failed : " . mysqli_error());
}
include('includes/functions.php');
if( isset($_SESSION['user']) ) {
$res=mysqli_query($conn, "SELECT * FROM users WHERE userId=".$_SESSION['user']);
$userRow=mysqli_fetch_array($res);
}
?>