Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( (isset($_POST['username'])) && (isset($_POST['password'])) )
- {
- $username=$_POST['username'];
- $password=$_POST['password'];
- $password_hash=md5($password);
- if(!empty($username)&&!empty($password))
- {
- $query="SELECT `id` , `Password` FROM `students` WHERE `Username`='$username' AND `Password`='$password_hash' ";
- if ($query_run=mysqli_query($connect,$query))
- {
- $query_num_rows=mysqli_num_rows($query_run);
- if ($query_num_rows==0)
- {
- echo ' Invalid Username/Password Combination';
- }
- else if ($query_num_rows==1)
- {
- $user_id=mysql_result($query_run,0,'id');
- $_SESSION['user_id']=$user_id;
- header('Location:Index.php');
- }
- }
- }
- else
- {
- echo 'You Must Enter a UserName and Password';
- }
- }
- ?>
- <form action="<?php echo $current_file; ?>" method="POST">
- Username : <input type="username" name="username">
- Password : <input type="password" name="password">
- <input type="submit" Value="Login">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement