Created
March 22, 2014 10:20
-
-
Save anonymous/9704354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- HTML --> | |
<form method='POST'> | |
<input placeholder='Name:' type='text' name='create_name' /> | |
<input placeholder='Username:' type='text' name='create_user' /> | |
<input placeholder='Password:' type='password' name='create_pass' /> | |
<select name='create_role'> | |
<option value='1'>Admin</option> | |
<option value='2'>Editor</option> | |
</select><br /> | |
<input class='sub_buttons' type='submit' name='create_submit' value='CREATE USER' /> | |
</form> | |
<!-- PHP --> | |
<?php | |
if(isset($_POST['create_submit'])){ | |
$result = mysql_query("SELECT * FROM users WHERE username = '$_POST[create_user]'"); | |
$check = mysql_fetch_assoc($result); | |
if($_POST['create_name'] == '' or $_POST['create_user'] == '' or $_POST['create_pass'] == '' or $_POST['create_name'] == 'Name:' or $_POST['create_user'] == 'Username:' or $_POST['create_pass'] == 'Password:'){ | |
echo " | |
<div class='row outputs'> | |
<div class='large-6 columns'> | |
Please fill out data in the fields! | |
</div> | |
</div> | |
"; | |
}elseif($_POST['username'] == $check['username']){ | |
echo "Username allready taken!"; | |
//header("location:".$_SERVER['PHP_SELF']."?taken=1"); | |
}else{ | |
$create_salt = "TKZO2kyVG22H3Xs".md5($_POST['create_pass'])."K2vG339F22F8W8c"; | |
mysql_query("INSERT INTO users (name, username, password, role) VALUES ('$_POST[create_name]', '$_POST[create_user]', '$create_salt', '$_POST[create_role]')") or die(mysql_error().$sql); | |
header("location:".$_SERVER['PHP_SELF']."?inserted=1"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment