Viewing file: login_process.php (1.19 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start(); if (isset($_POST['username']) and isset($_POST['password'])) { //3.1.1 Assigning posted values to variables. $username = $_POST['username']; $password = $_POST['password']; /* Atempt MySQL server connection. Assuming you are running MySQL server with default setting (user 'root' with no password) */ $link = mysqli_connect("localhost", "itceadidata", "bfiB3EhEKH854j5T", "itceadidata"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); }
// Attempt select query execution $sql = "SELECT * FROM branch WHERE username='$username' and password='$password' "; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_array($result)){ $_SESSION['username'] = $username; $_SESSION['loggedIn'] = $username; header("location: index.php"); } // Free result set mysqli_free_result($result); } else{ echo "Sorry....You are not registered"; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } // Close connection mysqli_close($link); ?>
|