Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*-----------------------------------------------------------------------*/
- /* Heinrich's News registration script V0.01 ALPHA */
- /*-----------------------------------------------------------------------*/
- $username = $_POST["username"];
- // connect (*IP, User, Password
- $con = mysql_connect("localhost","root","");
- //open database
- mysql_select_db("school", $con);
- /*----------------------*/
- /* PASSWORDS MD5 HASHED */
- /*----------------------*/
- $password = $_POST["password"];
- $rpassword = $_POST["rpassword"];
- $date = date("Y/m/d");
- /* DYNAMIC USER ID INSERT TO DB */
- $result = mysql_query("SELECT * FROM user ORDER BY userid DESC LIMIT 1");
- while($row = mysql_fetch_array($result))
- {
- $id = $row['userid']+1;
- }
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- /* default posts and userlevel */
- $posts = 0;
- //(admin 6),(normal user 1)
- $userlevel = 1;
- /*-------------------------*/
- /* Start Registration here */
- /*-------------------------*/
- /**/
- if (isset($_POST['submit']) == true) {
- $username = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $username);
- $password = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $password);
- }
- else if ((isset($_POST['submit']) == true) and (strlen($username) < 3) || (strlen($username) > 15)) {
- echo "Your username must be between 3 and 15 characters in length.";
- }
- else if ((isset($_POST['submit']) == true) and ((strlen($password) < 3) || (strlen($password) > 32) || (strlen($rpassword) < 3) || (strlen($rpassword) > 32))) {
- echo "The password must be between 3 and 32 characters in length.";
- }
- else if ((isset($_POST['submit']) == true) and ($password != $rpassword)) {
- echo "The passwords must be the same.";
- }
- else if ((isset($_POST['submit']) == true) and (($username == $password) || ($username == $rpassword))) {
- echo "The username and password cannot be the same.";
- }
- $sql = ("INSERT INTO user (userid, username, password, lastlog, posts, accessid)
- VALUES ('$id', '$username', '$password', '$date', '$userlevel')");
- else(isset($_POST['submit']) == true)
- {
- mysql_query($sql,$con);
- echo "username accepted, you have been registered";
- }
- die(mysql_error());
- mysql_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement