Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="form login" id="log_user">
- <input id="login__username" type="text" name="username" class="form__input" placeholder="Username" required>
- <input id="login__password" type="password" name="password" class="form__input" placeholder="Password" required>
- <input type="submit" value="Log In">
- </form>
- $(document).ready(function(){
- $("#log_user").submit(function(){
- $.ajax({
- type:"POST",
- data:{
- username : $("#login__username").val(),
- password : $("#login__password").val()
- },
- url:"log_user.php",
- success: function(data){
- if(data == 'Success'){
- alert('Login Passw correct');
- }
- else{
- alert(data);
- }
- },
- error: function(){
- alert('something went wrong');
- }
- });
- return false;
- });});
- <?php
- foreach(file('passwd.txt') as $line) {
- if(empty($line)) continue;
- $lineArray = explode(':', $line);
- $username = rtrim($lineArray[0]);
- $password = rtrim($lineArray[1]);
- if( isset($_POST['username']) && isset($_POST['password']) ){
- if($_POST['username'] == $username && $_POST['password'] == $password){
- session_start();
- $_SESSION['user'] = $username;
- echo "Success";
- }
- else{
- echo "Failed";
- }
- }
- }
- ?>
- myname:mypassw
- myname2:mypassw2
Add Comment
Please, Sign In to add comment