Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['submit']))
- {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $query = "select count(*) from tbl_users where username = '$username' and password = '$password'";
- $result = mysqli_query($conn, $query) or die ("Error in query: ".mysqli_error($conn));
- $row = mysqli_fetch_row($result);
- $counter = $row[0];
- echo $counter;
- if ($counter>0){
- $_SESSION['valid_user']=$username;
- }
- if (isset($_SESSION['valid_user']))
- {
- echo "You are logged in as: $_SESSION[valid_user]<br />";
- echo "<a href = 'logout.php'>Log Out</a><br />";
- }
- else{
- if((isset($username)) && (isset($password))){
- echo "Could not log you in. Incorrect username or password<br />";
- }
- else{
- echo "You are not logged in. <br />";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement