Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. <?php require_once('Connections/conn.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  
  8. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  9.  
  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.  
  38. $loginFormAction = $_SERVER['PHP_SELF'];
  39. if (isset($_GET['accesscheck'])) {
  40. $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  41. }
  42.  
  43. if (isset($_POST['username'])) {
  44. $loginUsername=$_POST['username'];
  45. $password=$_POST['pass'];
  46. $MM_fldUserAuthorization = "username";
  47. $MM_redirectLoginSuccess = "home.php";
  48. $MM_redirectLoginFailed = "login.php";
  49. $MM_redirecttoReferrer = false;
  50. mysql_select_db($database_conn, $conn);
  51.  
  52. $LoginRS__query=sprintf("SELECT username, pass, username FROM member WHERE username=%s AND pass=%s",
  53. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  54.  
  55. $LoginRS = mysql_query($LoginRS__query, $conn) or die(mysql_error());
  56. $loginFoundUser = mysql_num_rows($LoginRS);
  57. if ($loginFoundUser) {
  58.  
  59. $loginStrGroup = mysql_result($LoginRS,0,'username');
  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. ?>
  75. <html>
  76. <head>
  77. <title>session</title>
  78. </head>
  79.  
  80. <body>
  81. <form method="POST" action="<?php echo $loginFormAction; ?>">
  82. Please enter you name:
  83. <input type="text" id="username" name="username" />
  84. <input type="password" id="pass" name="pass" />
  85.  
  86. <input type="submit" value="Login" />
  87. </form>
  88. </body>
  89. </html>
  90.  
  91. <?php
  92. session_start();
  93.  
  94. ?>
  95.  
  96. <html>
  97. <head>
  98. <title>welcome</title>
  99. </head>
  100.  
  101. <body>
  102. <h1>Thnx for signing in</h1>
  103. <?php
  104. echo "Welcome" . " " . $_POST['username'];
  105. $_SESSION['chorva'] = $_POST['username'];
  106.  
  107.  
  108.  
  109.  
  110. ?>
  111.  
  112. </body>
  113. </html>
  114.  
  115. <?php
  116. session_start();
  117.  
  118. ?>
  119.  
  120. <html>
  121. <head>
  122. <title>welcome</title>
  123. </head>
  124.  
  125. <body>
  126. <h1>Thnx for signing in</h1>
  127. <?php
  128. echo "Welcome" . " " . $_SESSION['MM_Username'];
  129. $_SESSION['chorva'] = $_SESSION['MM_Username'];
  130.  
  131.  
  132.  
  133.  
  134. ?>
  135.  
  136. </body>
  137. </html>
  138.  
  139. <?php
  140. if(isset($_SESSION['MM_Username'])){
  141. echo "Welcome ".$_SESSION['MM_Username'];
  142. }
  143. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement