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'];
- if(strlen($username) != 0 && strlen($password) != 0) {
- $userExists = false;
- $file = fopen('users.txt', 'r');
- if(filesize('users.txt') > 0) {
- $usersFile = fread($file, filesize('users.txt'));
- $users = explode('*', $usersFile);
- for($i = 0; $i < count($users); $i++) {
- if($i % 2 != 0) {
- if(in_array($username, $users)) {
- $userExists = true;
- }
- }
- }
- }
- if($userExists) {
- echo "momxmarebeli ukve arsebobos";
- } else {
- $writeStreamInUsers = fopen('users.txt', 'a');
- $userInformation = "${password}*${username}*";
- fwrite($writeStreamInUsers, $userInformation);
- echo "tqven daregistrirdit";
- }
- } else {
- echo "sheavset yvela veli";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <form method="POST">
- <input type="text" name="username" placeholder="username" /> <br /> <br />
- <input type="password" name="password" placeholder="password" /> <br /> <br />
- <input type="submit" name="submit" value="register" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement