Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("db.php");
- if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
- {
- //Prevent SQL injections
- $username = mysql_real_escape_string($_POST['username']);
- $email = mysql_real_escape_string($_POST['email']);
- //Get MD5 hash of password
- $password = md5($_POST['password']);
- //Check to see if username exists
- $sql = mysql_query("SELECT `username` FROM `users` WHERE `username` = '".$username."'");
- if(mysql_num_rows($sql) > 0)
- {
- die ("Username taken.");
- }
- mysql_query("INSERT INTO users (username, pass, email) VALUES ( '$username', '$password', '$email')") or die (mysql_error()); echo "Account created.";
- }
- ?>
- <form action="register.php" method="post">
- Username: <input name="username" type="text" /><br>
- Password: <input type="password" name="password" /><br>
- Email: <input name="email" type="text" /><br>
- <input type="submit" value="Submit" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement