daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include("config.php");
  3. class Process
  4. {
  5.     function Process($connection){
  6.         if(isset($_POST['login'])){
  7.         $this->login();
  8.         }
  9.         elseif(isset($_POST['register'])){
  10.         $this->register();
  11.         }
  12.         else{
  13.         header("Location: login.php");
  14.         }
  15.     }
  16.     //Member Login
  17.     function login(){
  18.     global $config;
  19.         ob_start();
  20.          
  21.         // Define $myusername and $mypassword
  22.         $myusername=$_POST['myusername'];
  23.         $mypassword=$_POST['mypassword'];
  24.          
  25.         # Allows letters, numbers
  26.         if(!preg_match('/^[a-zA-Z0-9]+$/i', $myusername))  
  27.         {
  28.         session_register(bad_char);
  29.         $_SESSION['bad_char'] = "<center><font color='red' size='1'>Invalid Charcter; Only Letters Or Numbers Can Be Used!</font></center>";
  30.         header("location:login.php");
  31.         }
  32.  
  33.         // To protect MySQL injection (more detail about MySQL injection)
  34.         $myusername = stripslashes($myusername);
  35.         $mypassword = stripslashes($mypassword);
  36.         $myusername = mysql_real_escape_string($myusername);
  37.         $mypassword = mysql_real_escape_string($mypassword);
  38.         $encrypt_password = md5($mypassword);
  39.         $query = $config->query("SELECT * FROM members WHERE username='".$myusername."' and password='".$encrypt_password."'");
  40.          
  41.         // Mysql_num_row is counting table row
  42.         $count=mysql_num_rows($query);
  43.         // If result matched $myusername and $mypassword, table row must be 1 row
  44.          
  45.         if($count==1){
  46.         // Register $myusername, $mypassword and redirect to file "login_success.php"
  47.         session_register("myusername");
  48.         header("location:main.php");
  49.         }
  50.         else {
  51.         session_register(error);
  52.         $_SESSION['error'] = "<center><font color='red' size='4'>Wrong Username or Password</font></center>";
  53.         header("location:login.php");
  54.         }
  55.          
  56.         ob_end_flush();
  57.     }
  58.      
  59.     //Register_Submit
  60.     function register(){
  61.     global $config;
  62.      
  63.         //Defines All The Users Inputs
  64.         $myusername=$_POST['myusername'];
  65.         $myusername2=$_POST['myusername'];
  66.         $mypassword=$_POST['mypassword'];    
  67.         $mypassword2=$_POST['mypassword2'];
  68.         $email=$_POST['email'];
  69.         $passwordcount=$_POST['mypassword'];
  70.          
  71.         # Allows letters, numbers
  72.         if(!preg_match('/^[a-zA-Z0-9]+$/i', $myusername2))  
  73.         {
  74.         session_register(bad_char);
  75.         $_SESSION['bad_char'] = "<center><font color='red' size='1'>Invalid Charcter; Only Letters Or Numbers Can Be Used!</font></center>";
  76.         header("location:register.php");
  77.         }
  78.          
  79.          
  80.         //Stop SQL Injection
  81.         $myusername = stripslashes($myusername);
  82.         $mypassword = stripslashes($mypassword);
  83.         $mypassword2 = stripslashes($mypassword2);
  84.         $email = stripslashes($email);
  85.         $myusername = mysql_real_escape_string($myusername);
  86.         $mypassword = mysql_real_escape_string($mypassword);
  87.         $mypassword2 = mysql_real_escape_string($mypassword2);
  88.         $email = mysql_real_escape_string($email);
  89.          
  90.         //encrypt password variable
  91.         $encrypt_password = md5($mypassword);
  92.          
  93.         $query = $config->query("SELECT * FROM members WHERE username='".$myusername."'");
  94.          
  95.         // Mysql_num_row is counting table row
  96.         $count=mysql_num_rows($query);
  97.         // If result matches $myusername then username is taken
  98.          
  99.         if($count===1){
  100.         // Send error back to the register page if count = 1
  101.         session_register(username_taken);
  102.         $_SESSION['username_taken'] = "<center><font color='red' size='1'>The Username You Chose Is Already In Use</font></center>";
  103.         header("location:register.php");
  104.         }    
  105.         elseif($mypassword != $mypassword2)
  106.         {
  107.         session_register(password_same);
  108.         $_SESSION['password_same'] = "<center><font color='red' size='1'>Passwords Dont Match</font></center>";
  109.         header("location:register.php");
  110.         }
  111.         elseif(strlen($mypassword) < "5")
  112.         {
  113.         session_register(password_less_then_5);
  114.         $_SESSION['password_less_then_5'] = "<center><font color='red' size='1'>Password Must be Greater then 4 Charcters</font></center>";
  115.         header("location:register.php");
  116.         }
  117.         else
  118.         {
  119.         $query = $config->query("INSERT INTO members (id, username, password, email) VALUES (NULL, '$myusername', '$encrypt_password', '$email')");
  120.         session_register(welcome_screen);
  121.         $_SESSION['welcome'] =  
  122.         "Welcome, You are now a member of Corpal Uploads.<br>
  123.         Reccommend us to your friends.<br>
  124.         We are a free Upload site and WILL STAY FREE!<br>
  125.         Thanks,<br>
  126.         Whitey.<br>
  127.         <a href='login.php'>Continue</a>";
  128.         header("location: register.php");
  129.         }
  130.      
  131.     }
  132. };
  133. $process = new Process($connection);
  134. ?>
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