Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); // Starting Session
- $error=''; // Variable To Store Error Message
- if (isset($_POST['submit'])) {
- if (empty($_POST['username']) || empty($_POST['password'])) {
- $error = "Username or Password is invalid";
- }
- else
- {
- // Define $username and $password
- $username=$_POST['username'];
- $password=$_POST['password'];
- $connection = mysqli_connect("localhost", "username", "password", "dbname");
- $query = mysql_real_query("select * from login where password='$password' AND username='$username'", $connection);
- $rows = mysql_num_rows($query);
- if ($rows == 1) {
- $_SESSION['login_user']=$username; // Initializing Session
- header("location: profile.php"); // Redirecting To Other Page
- } else {
- $error = "Username or Password is invalid";
- }
- mysql_close($connection); // Closing Connection
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement