Viewing file: logincheck.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", "sql_itce_co_in", "02a26fb2e4265", "sql_itce_co_in"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } // Attempt select query execution $sql = "SELECT * FROM studentlogin 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: branchpage.php"); } echo "</table>"; // 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); ?>
|