daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. require_once("config.php");
  4.  
  5. if (!isset ($_POST['submit'])) { ?>
  6.  
  7. <html>
  8.     <head>
  9.         <title>Register</title>
  10.         <style type="text/css">
  11.         background { background: #f2f2f2; font-family: Arial, sans-serif;}
  12.         form { padding: 10px; background: #222; color: #fff; font-size: 16px; font-family: Arial, sans-serif; }
  13.         .center { margin-left: auto; margin-right: auto; max-width: 450px; }
  14.         </style>
  15.     </head>
  16.     <body>
  17.         <div class="center">
  18.         <form action="register.php" method="post">
  19.         Email: <input type="text" name="email" value="" /><br>
  20.         First Name: <input type="text" name="firstname" value="" /><br>
  21.         Last Name: <input type="text" name="lastname" value="" /><br>
  22.         Username: <input type="text" name="username" value="" /><br>
  23.         Password: <input type="password" name="password" value="" /><br>
  24.         Verify Password: <input type="password" name="verify" value="" /><br>
  25.         <input type="submit" name="submit" />
  26.         </form>
  27.         </div>
  28.     </body>
  29. </html>
  30.  
  31. <?php }
  32.  
  33.     if (isset($_POST['submit'])) {
  34.  
  35.     // define variables
  36.     $username = $_POST['username'];
  37.     $firstname = $_POST['firstname'];
  38.     $lastname = $_POST['lastname'];
  39.     $password = $_POST['password'];
  40.     $verify = $_POST['verify'];
  41.     $email = $_POST['email'];
  42.     $ip = $_SERVER[REMOTE_ADDR];
  43.    
  44.     function cleanQuery($string) {
  45.     $badWords = array("/delete/i", "/update/i","/union/i","/insert/i","/drop/i","/http/i","/--/i");
  46.     $string = preg_replace($badWords, "", $string);
  47.  
  48.       if(get_magic_quotes_gpc())  // prevents duplicate backslashes {
  49.         $string = stripslashes($string); }
  50.       if (phpversion() >= '4.3.0') {
  51.         $string = mysql_real_escape_string($string); }
  52.       else {
  53.         $string = mysql_escape_string($string); }
  54.       return $string
  55.           }
  56.    
  57.     function checkChars($chars) {
  58.     if (ereg("[^A-Za-z]", $chars))
  59.         echo "A - Z Only! Characters have been removed.";
  60.     else
  61.         echo "Nothing to see here...";
  62.     }
  63.        
  64.     function checkEmpty($empty) {
  65.     if (empty($empty))
  66.         echo "<div style=\"color:#ff0000;\">Field Required</div>";
  67.     }
  68.        
  69.     // ereg_replace("[^A-Za-z]", "", $_POST['$replace']);
  70.        
  71.     function replaceChars() {
  72.    
  73.         $thechar = $_POST['firstname'];
  74.        
  75.         $new = preg_replace("/[^a-z]/i", "", $thechar);
  76.        
  77.         echo $new;
  78.     }
  79.    
  80.     if (empty($username) || empty($firstname) || empty($lastname) || empty($password) || empty($verify)) { ?>
  81.    
  82.             <html>
  83.                 <head>
  84.                     <title>Register</title>
  85.                     <style type="text/css">
  86.                     background { background: #f2f2f2; font-family: Arial, sans-serif;}
  87.                     form { padding: 10px; background: #222; color: #fff; font-size: 16px; font-family: Arial, sans-serif; }
  88.                     .center { margin-left: auto; margin-right: auto; max-width: 450px; }
  89.                     </style>
  90.                 </head>
  91.                 <body>
  92.                     <div class="center">
  93.                     <form action="register.php" method="post">
  94.                     Email: <input type="text" name="email" value="" /><br>
  95.                     Last Name: <input type="text" name="lastname" value="<?php echo "$lastname"; ?>" /> <?php checkEmpty("$lastname"); ?><br>
  96.                     Username: <input type="text" name="username" value="<?php echo "$username"; ?>" /> <?php checkEmpty("$username"); ?><br>
  97.                     Password: <input type="password" name="password" value="<?php echo "$password"; ?>" /> <?php checkEmpty("$password"); ?><br>
  98.                     Verify Password: <input type="password" name="verify" value="<?php echo "$verify"; ?>" /> <?php checkEmpty("$verify"); ?><br>
  99.                     <input type="submit" name="submit" />
  100.                     </form>
  101.                     </div>
  102.                 </body>
  103.             </html>
  104.  
  105. <?php }
  106.        
  107. else {
  108.  
  109. $to = $email;
  110. $subject = "Welcome";
  111. $message = "You've been registered.";
  112. $from = "example@google.com";
  113. $headers = "From: $from";
  114. mail($to,$subject,$message,$headers);
  115. echo "Mail Sent.";         
  116.        
  117. $query = mysql_query("INSERT INTO users (username,password,ip,firstname,lastname) VALUES ('$username','".md5($password)."','$ip','$firstname','$lastname')") or die ("Registration Failed.");
  118.  
  119. echo "Welcome $_POST[username]! You've been successfully reigstered!<br /><br />
  120.     Please login <a href='login.php'><b>here</b></a>.";
  121.            
  122.     exit();
  123.     }
  124. }
  125.  
  126. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top