Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //for connecting to the database
- mysql_connect("mysql7.000webhost.com","a8839106_enoch","dragon1") or
- die(mysql_error());
- mysql_select_db("users") or die (mysql_error());
- //if the form has been submitted
- if (isset($_POST['submit'])) {
- //in case they leave out blank fields
- if (!$_POST['username'] | !$_POST['pass'] | !$_POST['email']) {
- die ('Please fill in all required fields');
- }
- //check if username is in use
- if (!get_magic_quotes_gpc()) {
- $_POST['username'] = addslashes($_POST['username']); }
- $usercheck= $_POST['username'];
- $check =mysql_query("SELECT username FROM users WHERE username= '$usercheck'")
- or die("Username in use");
- //second check
- if($check2 !=0) {
- die ('Sorry,the username '.$_POST['username'].' is already in use.');
- //password encryption using md5
- $_POST['pass'] = md5($_POST['pass']);
- if (!get_magic_quotes_gpc()) {
- $_POST['pass'] = addslashes($_POST['pass']);
- $_POST['username'] = addslashes($_POST['username']);
- }
- //inserting it in the database
- $insert = "INSERT INTO users (username, password)
- VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
- $add_user = mysql_query($insert);
- echo "<h1> Welcome! You were successfully
- registered! </h1>";
- echo '<h1> <a href="login.html"> Go to the signin page </a> </h1>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment