Guest User

Untitled

a guest
Nov 16th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1. <?php require_once('Connections/loginconnect.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. mysql_select_db($database_loginconnect, $loginconnect);
  35. $query_Recordset1 = "SELECT * FROM Login";
  36. $Recordset1 = mysql_query($query_Recordset1, $loginconnect) or die(mysql_error());
  37. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  38. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  39. ?>
  40. <?php
  41. // *** Validate request to login to this site.
  42. if (!isset($_SESSION)) {
  43.   session_start();
  44. }
  45.  
  46. $loginFormAction = $_SERVER['PHP_SELF'];
  47. if (isset($_GET['accesscheck'])) {
  48.   $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  49. }
  50.  
  51. if (isset($_POST['username'])) {
  52.   $loginUsername=$_POST['username'];
  53.   $password=$_POST['password'];
  54.   $MM_fldUserAuthorization = "";
  55.   $MM_redirectLoginSuccess = "members.php";
  56.   $MM_redirectLoginFailed = "login.php";
  57.   $MM_redirecttoReferrer = true;
  58.   mysql_select_db($database_loginconnect, $loginconnect);
  59.  
  60.   $LoginRS__query=sprintf("SELECT `user` FROM Login WHERE `user`=%s",
  61.     GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text"));
  62.    
  63.   $LoginRS = mysql_query($LoginRS__query, $loginconnect) or die(mysql_error());
  64.   $loginFoundUser = mysql_num_rows($LoginRS);
  65.   if ($loginFoundUser) {
  66.      $loginStrGroup = "";
  67.    
  68.     if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  69.     //declare two session variables and assign them
  70.     $_SESSION['MM_Username'] = $loginUsername;
  71.     $_SESSION['MM_UserGroup'] = $loginStrGroup;      
  72.  
  73.     if (isset($_SESSION['PrevUrl']) && true) {
  74.       $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; 
  75.     }
  76.     header("Location: " . $MM_redirectLoginSuccess );
  77.   }
  78.   else {
  79.     header("Location: ". $MM_redirectLoginFailed );
  80.   }
  81. }
  82. ?>
Add Comment
Please, Sign In to add comment