Advertisement
Guest User

Untitled

a guest
Jun 16th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. <?php require_once('Connections/trabalhoCD.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. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10. switch ($theType) {
  11. case "text":
  12. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13. break;
  14. case "long":
  15. case "int":
  16. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17. break;
  18. case "double":
  19. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  20. break;
  21. case "date":
  22. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23. break;
  24. case "defined":
  25. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26. break;
  27. }
  28. return $theValue;
  29. }
  30. }
  31. ?>
  32. <?php
  33. // Validate request to login to this site.
  34. if (!isset($_SESSION)) {
  35. session_start();
  36. }
  37. $loginFormAction = $_SERVER['PHP_SELF'];
  38. if (isset($_GET['accesscheck'])) {
  39. $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  40. }
  41. if (isset($_POST['login'])) {
  42. $loginUsername=$_POST['login'];
  43. $password=md5($_POST['pass']);
  44. $MM_fldUserAuthorization = "";
  45. $MM_redirectLoginSuccess = "tabela1.php";
  46. $MM_redirectLoginFailed = "login2.php";
  47. $MM_redirecttoReferrer = false;
  48. mysql_select_db($database_trabalhoCD, $trabalhoCD);
  49.  
  50. $LoginRS__query=sprintf("SELECT login, pass FROM utilizador WHERE login=%s AND pass=%s",
  51. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  52.  
  53. $LoginRS = mysql_query($LoginRS__query, $trabalhoCD) or die(mysql_error());
  54. $loginFoundUser = mysql_num_rows($LoginRS);
  55. if ($loginFoundUser) {
  56. $loginStrGroup = "";
  57.  
  58. if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  59. //declare two session variables and assign them
  60. $_SESSION['MM_Username'] = $loginUsername;
  61. $_SESSION['MM_UserGroup'] = $loginStrGroup;
  62. if (isset($_SESSION['PrevUrl']) && false) {
  63. $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  64. }
  65. header("Location: " . $MM_redirectLoginSuccess );
  66. }
  67. else {
  68. header("Location: ". $MM_redirectLoginFailed );
  69. }
  70. }
  71. ?>
  72. <!doctype html>
  73. <html>
  74. <head>
  75. <meta charset="UTF-8">
  76. </head>
  77. <body>
  78. <form ACTION="<?php echo $loginFormAction; ?>" method="POST" name="form" id="form">
  79. <table width="600" border="1">
  80. <tbody>
  81. <tr>
  82. <th width="173" scope="row"><label for="login">Login:</label></th>
  83. <td width="411">
  84. <input name="login" type="text" id="login" size="20" maxlength="20"></td>
  85. </tr>
  86. <tr>
  87. <th scope="row"><label for="pass">Password:</label></th>
  88. <td>
  89. <input name="pass" type="password" id="pass" size="20" maxlength="20"></td>
  90. </tr>
  91. <tr>
  92. <th colspan="2" scope="row"><input type="reset" name="limpar" id="limpar" value="limpar">
  93. <input type="submit" name="enviar" id="enviar" value="enviar"></th>
  94. </tr>
  95. </tbody>
  96. </table>
  97. </form>
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement