Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submit'])) {
- mysql_connect("localhost", "root", "") or die(mysql_error());
- mysql_select_db("noveen") or die(mysql_error());
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty($password) || empty($username)) {
- echo "You need to fill out the form first.";
- exit();
- }
- $md5 = md5($password);
- $check = mysql_query("SELECT `username` FROM `users` WHERE `username` = $username") or die(mysql_error());
- $num = mysql_num_rows($check);
- if($num === 1) {
- echo "Your username is already in use.";
- exit();
- }
- else {
- mysql_query("INSERT INTO `users` (username, password) VALUES ($username, $md5)") or die(mysql_error());
- }
- echo "You have successfully registered.";
- }
- else {
- echo "Please fill out the form below.";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement