Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Loggin</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <div class="loggin">
- <form method="POST">
- <label for="user">User Name:</label>
- <input type="text" name="userName" id="user">
- <br>
- <label for="pass">Password:</label>
- <input type="password" name="password" id="pass">
- <br>
- <a href="Profile.php"><input type="submit" name="submit" value="Submit" /></a>
- </form>
- <form method="POST" action="Registration.php">
- <input type="submit" name="register" value="Register" />
- </form>
- </div>
- <?php
- $userName = trim($_POST['userName']);
- $userPass = trim($_POST['password']);
- $string = file_get_contents('data.txt');
- $string = explode("\n", $string);
- $error = true;
- foreach ($string as $key => $value) {
- $value = explode("!", $value);
- if (($userName === $value[0]) && ($userPass === $value[1])) {
- $error = false;
- break;
- }
- }
- if (empty($_POST['userName']) || empty($_POST['password'])) {
- echo "<p>You have to fill all fields!</p>";
- }
- if ($error) {
- echo "<p>Invalid username or password!</p>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment