Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.66 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------*/
  3. /*                  Registration page by Nathan Heinrich             */
  4. /*                      ALPHA V0.02                          */
  5. /*-----------------------------------------------------------*/
  6. //Connect to database and select the database
  7.     $con = mysql_connect("localhost","root","");
  8.     mysql_select_db("famenews", $con);
  9. //Supply the latest login date
  10.     $date = date("Y/m/d");
  11. // Username and password
  12.     $username= $_POST['username'];
  13. /*----------------------*/
  14. /* PASSWORDS MD5 HASHED */
  15. /*----------------------*/
  16.     $password = md5($_POST['password']);
  17.     $rpassword = md5($_POST['rpassword']);
  18. /* DYNAMIC USER ID INSERT TO DB */
  19.     $accessid = 1;
  20.     mysql_select_db("school", $con);
  21.     $result = mysql_query("SELECT * FROM user ORDER BY userid DESC LIMIT 1");
  22.     while($row = mysql_fetch_array($result))
  23.     {
  24.         $id = $row['userid']+1;
  25.     }
  26.     $sql = ("INSERT INTO user (userid, username, password, lastlog, posts, accessid)
  27.     VALUES ('$id', '$username', '$password', '$date', '$posts', '$accessid')");
  28. // END VARIABLES HERE
  29. //------------------------------------------------------------------------------
  30. //------------------------------------------------------------------------------
  31. if ((isset($_POST['submit']) == true) and (strlen($username) < 3) || (strlen($username) > 15)) {
  32. echo "Your username must be between 3 and 15 characters in length.";
  33. }
  34. else if ((isset($_POST['submit']) == true) and ((strlen($password) < 3) || (strlen($password) > 32) || (strlen($rpassword) < 3) || (strlen($rpassword) > 32))) {
  35. echo "The password must be between 3 and 32 characters in length.";
  36. }
  37.  
  38. else if ((isset($_POST['submit']) == true) and ($password != $rpassword)) {
  39. echo "The passwords must be the same.";
  40. }
  41.  
  42. else if ((isset($_POST['submit']) == true) and (($username == $password) || ($username == $rpassword))) {
  43. echo "The username and password cannot be the same.";
  44. }
  45. else {
  46.     if (!$con)
  47.         {
  48.         die('Could not connect: ' . mysql_error());
  49.         }
  50.     if (isset($_POST['submit']) == true)
  51.         {
  52.         (!mysql_query($sql,$con));
  53.         {
  54.         die(' ' . mysql_error());
  55.         }
  56.  
  57.         }
  58.     if (isset($_POST['del']) == true)
  59.         {
  60.         $del = ("INSERT INTO cms (id, date, admin, news, title)
  61.         VALUES ('$id', '$date', '$_POST[admin]', '$_POST[news]', '$_POST[title]')");
  62.         }
  63.     echo '<form action="#" method="post">';
  64.     echo 'Username: <input type="username" name="username" />';
  65.     echo 'Password: <input type="password" name="password" />';
  66.     echo 'Repeat password: <input type="password" name="rpassword" />';
  67.     echo '<input type="submit" name="submit" />';
  68.     echo '</form>';
  69.       mysql_close($con);
  70.       }
  71. /* If the IP address of the visitor is not allowed, send a GTFO message. */
  72.                  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement