Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- mysql_connect('localhost', 'root', '');
- mysql_select_db('membership');
- if (isset($_POST['submit']))
- {
- $username = $_POST['user'];
- $password = md5($_POST['pass']);
- $query = mysql_query("SELECT * FROM users WHERE username = '" . $username . "'");
- if (mysql_num_rows($query) == 0)
- {
- echo 'Success';
- $insert = mysql_query("INSERT INTO users (username, password) VALUES('$username', '$password')");
- }
- else
- {
- echo 'Username already taken';
- echo '<br><a href="register.php">Go Back</a>';
- }
- }
- else
- {
- ?>
- <form method="POST">
- <label for="user">Username:</label>
- <input type="text" name="user" /><br />
- <label for="pass">Password:</label>
- <input type="text" name="pass" size="5" /><br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement