Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // require common code
- require_once("includes/common.php");
- // check if username or password is blank
- if ($_POST["username"]|$_POST["password"] == "")
- {
- // apologize
- apologize("Type username/password!");
- }
- // check if password is equal to password2
- if ($_POST["password"] != $_POST["password2"])
- {
- // apologize
- apologize("The passwords are not equal!");
- }
- // escape username to avoid SQL injection attacks
- $username = mysql_real_escape_string($_POST["username"]);
- // encrypt the passwords and store it as hash value
- $hash = crypt($_POST["password"]);
- mysql_query('INSERT INTO users (username, hash, cash) VALUES (' . $username . ', ' . $hash . ', 10000.00)')or die(mysql_error());
- // look in the database if username already exists
- if (mysql_query($sql) != UNIQUE)
- {
- return 0;
- apologize("Username already exists!");
- }
- // remember that user's now logged in by caching user's ID in session
- $_SESSION["id"] = $row["id"];
- // redirect to portfolio
- redirect("index.php");
- // else report error
- apologize("Invalid username and/or password!");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment