Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1.  <html>
  2.  <head>
  3.  <style type="text/css" media="all">
  4.         <!--
  5. body {
  6.     background-image: url(imagens/background_home.jpg);
  7.     background-repeat: no-repeat;
  8.     background-attachment: scroll;
  9.     background-position: center 0;
  10.     margin: 0;
  11. }
  12.  
  13.  
  14.  </style>
  15.  </head>
  16.  
  17.  
  18.  <?php
  19.  // Connects to your Database
  20.  
  21.  mysql_connect("localhost", "iskull", "iskull") or die(mysql_error());
  22.  
  23.  mysql_select_db("users") or die(mysql_error());
  24.  
  25.  
  26.  //This code runs if the form has been submitted
  27.  
  28.  if (isset($_POST['submit'])) {
  29.  
  30.  
  31.  
  32.  //This makes sure they did not leave any fields blank
  33.  
  34.  if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  35.  
  36.         die('You did not complete all of the required fields');
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.  // checks if the username is in use
  43.  
  44.     if (!get_magic_quotes_gpc()) {
  45.  
  46.         $_POST['username'] = addslashes($_POST['username']);
  47.  
  48.     }
  49.  
  50.  $usercheck = $_POST['username'];
  51.  
  52.  $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
  53.  
  54. or die(mysql_error());
  55.  
  56.  $check2 = mysql_num_rows($check);
  57.  
  58.  
  59.  
  60.  //if the name exists it gives an error
  61.  
  62.  if ($check2 != 0) {
  63.  
  64.         die('Sorry, the username '.$_POST['username'].' is already in use.');
  65.  
  66.                 }
  67.  
  68.  
  69.  // this makes sure both passwords entered match
  70.  
  71.     if ($_POST['pass'] != $_POST['pass2']) {
  72.  
  73.         die('Your passwords did not match. ');
  74.  
  75.     }
  76.  
  77.  
  78.  
  79.     // here we encrypt the password and add slashes if needed
  80.  
  81.     $_POST['pass'] = md5($_POST['pass']);
  82.  
  83.     if (!get_magic_quotes_gpc()) {
  84.  
  85.         $_POST['pass'] = addslashes($_POST['pass']);
  86.  
  87.         $_POST['username'] = addslashes($_POST['username']);
  88.  
  89.             }
  90.  
  91.  
  92.  
  93.  // now we insert it into the database
  94.  
  95.     $insert = "INSERT INTO users (username, password)
  96.  
  97.             VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
  98.  
  99.     $add_member = mysql_query($insert);
  100.  
  101.     ?>
  102.    
  103.    
  104.  <h1>Registered</h1>
  105.  
  106.  <p>Thank you, you have registered - you may now login</a>.</p>
  107.  
  108.  <?php
  109.  }
  110.  
  111.  else
  112.  { 
  113.  ?>
  114.  
  115.  
  116.  
  117.  
  118.  
  119. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  120.  
  121.  <table width="501" border="0">
  122.  
  123.  <tr><td width="139">Username:</td><td width="352">
  124.  
  125.  <input type="text" name="username" maxlength="60">
  126.  
  127.  </td></tr>
  128.  
  129.  <tr><td>Password:</td><td>
  130.  
  131.  <input type="password" name="pass" maxlength="10">
  132.  
  133.  </td></tr>
  134.  
  135.  <tr><td>Confirm Password:</td><td>
  136.  
  137.  <input type="password" name="pass2" maxlength="10">
  138.  
  139.  </td></tr>
  140.  
  141.  <tr><th colspan=2><input type="submit" name="submit"
  142. value="Register"></th></tr> </table>
  143.  
  144.  </form>
  145.  
  146.  
  147.  <?php
  148.  
  149.  }
  150.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement