Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <font color="white">
- <?php
- include("config/db.php");
- //This code runs if the form has been submitted
- if (isset($_POST['submit'])) {
- //This makes sure they did not leave any fields blank
- if (!$_POST['username'] | !$_POST['pass'] | !$_POST['cpass']) {
- die('You did not complete all of the required fields');
- }
- // checks if the username is in use
- if (!get_magic_quotes_gpc()) {
- $_POST['username'] = addslashes($_POST['username']);
- }
- $usercheck = $_POST['username'];
- $check = mysql_query("SELECT name FROM accounts WHERE name = '$usercheck'") or die(mysql_error());
- $check2 = mysql_num_rows($check);
- //if the name exists it gives an error
- if ($check2 != 0) {
- die('Sorry, the username '.$_POST['username'].' is already in use.');
- }
- if ($_POST['pass'] != $_POST['cpass']) {
- die('Your passwords did not match. ');
- }
- // here we encrypt the password and add slashes if needed
- $_POST['pass'] = sha1($_POST['pass']);
- if (!get_magic_quotes_gpc()) {
- $_POST['pass'] = addslashes($_POST['pass']);
- $_POST['username'] = addslashes($_POST['username']);
- }
- // now we insert it into the database
- $insert = "INSERT INTO accounts (name, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
- $add_member = mysql_query($insert);
- echo" <center>Your account has successfully been created! You may now login!</center>";
- }
- ?>
- </font>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement