Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "127.0.0.1";
- $username = "root";
- $password = "";
- $db = "aibnb";
- global $conn;
- global $sql;
- // Create connection
- $conn = new mysqli($servername, $username, $password, $db);
- if ($conn->connect_error) {
- header('location: install.php');
- exit();
- }
- /*$conn = mysqli_connect("", "", "", "");
- // Evaluate the connection
- if (mysqli_connect_errno()) {
- header('location: install.php');
- exit();
- }*/
- function settings($conn,$what,$from) {
- $sql = "SELECT $what FROM $from";
- $result = $conn->query($sql);
- $row = $result->fetch_assoc();
- return $row[$what];
- }
- function login($conn,$user,$pass) {
- $sql = "SELECT user FROM users WHERE user='$user' AND pass='$pass'";
- $result = $conn->query($sql);
- //$num_row = mysqli_num_rows($result);
- if( $result->num_rows ) {
- while( $row=mysqli_fetch_array($result) ){
- session_start();
- $_SESSION['userid'] = $row['user'];
- }
- } else {
- return false;
- }
- return true;
- }
- <?php
- include($_SERVER['DOCUMENT_ROOT'].'/assets/php/conn.php');
- include($_SERVER['DOCUMENT_ROOT'].'/assets/php/session.php');
- if(isset($_SESSION["roomid"])) { $roomid = $_SESSION["roomid"]; }
- else { $_SESSION["roomid"] = rand(1000000,9999999);
- $roomid = $_SESSION["roomid"];
- }
- $nimic = "<font color=''>empty</font>";
- $sql = "SELECT id,fname,lname,role FROM users WHERE user='$userid'";
- $result = $conn->query($sql);
- //$num_row = mysqli_num_rows($result);
- if($result->num_rows ) {
- while( $row=mysqli_fetch_array($result) ){ extract($row);
- $uid = $id; $name = $fname." ".$lname; $role = $role; }
- } else { echo "empty"; } $back = '<a href="?"> back </a>|';
- function alert($msg,$m){
- echo '<div data-alert class="alert-box '.($m==0 ? 'warning' : 'success').' radius">
- '.$msg.'
- <a href="#" class="close">×</a>
- </div>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement