Advertisement
geouser

codigos misqli

Oct 30th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.37 KB | None | 0 0
  1. <?php require_once('../Connections/conexao.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.     global $conexao;
  7.   if (PHP_VERSION < 6) {
  8.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9.   }
  10.  $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexao, $theValue) : mysqli_escape_string($conexao, $theValue);
  11.     switch ($theType) {
  12.     case "text":
  13.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14.       break;    
  15.     case "long":
  16.     case "int":
  17.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18.       break;
  19.     case "double":
  20.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  21.       break;
  22.     case "date":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;
  25.     case "defined":
  26.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27.       break;
  28.   }
  29.   return $theValue;
  30. }
  31. }
  32. ?>
  33. <?php
  34. // *** Validate request to login to this site.
  35. if (!isset($_SESSION)) {
  36.   session_start();
  37. }
  38.  
  39. $loginFormAction = $_SERVER['PHP_SELF'];
  40. if (isset($_GET['accesscheck'])) {
  41.   $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  42. }
  43.  
  44. if (isset($_POST['login'])) {
  45.   $loginUsername=$_POST['login'];
  46.   $password=$_POST['senha'];
  47.   $MM_fldUserAuthorization = "";
  48.   $MM_redirectLoginSuccess = "painel.php";
  49.   $MM_redirectLoginFailed = "erro_login.php";
  50.   $MM_redirecttoReferrer = false;
  51.   mysqli::select_db("$sistema de login","$conexao");
  52.  
  53.   $LoginRS__query=sprintf("SELECT login, senha FROM usuarios WHERE login=%s AND senha=%s",
  54.     GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  55.    
  56.   $LoginRS = mysqli_query($connSQL, $LoginRS__query) or die(mysqli_error());
  57.   $loginFoundUser = mysqli_num_rows($LoginRS);
  58.   if ($loginFoundUser) {
  59.      $loginStrGroup = "";
  60.    
  61.     //declare two session variables and assign them
  62.     $_SESSION['MM_Username'] = $loginUsername;
  63.     $_SESSION['MM_UserGroup'] = $loginStrGroup;      
  64.  
  65.     if (isset($_SESSION['PrevUrl']) && false) {
  66.       $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; 
  67.     }
  68.     header("Location: " . $MM_redirectLoginSuccess );
  69.   }
  70.   else {
  71.     header("Location: ". $MM_redirectLoginFailed );
  72.   }
  73. }
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement