PageRenderTime 82ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/neticketing/login.php

https://bitbucket.org/mac_pasha/neticketing
PHP | 184 lines | 164 code | 16 blank | 4 comment | 27 complexity | 10aedc15e2c808edb054d6fb8c23acd1 MD5 | raw file
  1. <?php require_once('Connections/neticketing.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['inputEmail'])) {
  42. $loginUsername=$_POST['inputEmail'];
  43. $password=$_POST['inputPassword'];
  44. $MM_fldUserAuthorization = "";
  45. $MM_redirectLoginSuccess = "dashboard.php";
  46. $MM_redirectLoginFailed = "login.php";
  47. $MM_redirecttoReferrer = true;
  48. mysql_select_db($database_neticketing, $neticketing);
  49. $LoginRS__query=sprintf("SELECT user_email, user_password, user_id FROM user_info WHERE user_email=%s AND user_password=%s",
  50. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  51. $LoginRS = mysql_query($LoginRS__query, $neticketing) or die(mysql_error());
  52. $loginFoundUser = mysql_num_rows($LoginRS);
  53. $forUserId = mysql_fetch_assoc($LoginRS);
  54. if ($loginFoundUser) {
  55. $loginStrGroup = "";
  56. if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  57. //declare two session variables and assign them
  58. $_SESSION['MM_Username'] = $loginUsername;
  59. $_SESSION['MM_UserGroup'] = $loginStrGroup;
  60. $_SESSION['user_email'] = $_POST['inputEmail'];
  61. $_SESSION['user_id'] = $forUserId['user_id'];
  62. if (isset($_SESSION['PrevUrl']) && true) {
  63. $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  64. }
  65. header("Location: " . $MM_redirectLoginSuccess );
  66. }
  67. else {
  68. header("Location: ". $MM_redirectLoginFailed );
  69. }
  70. }
  71. ?>
  72. <?php
  73. // *** Validate request to login to this site.
  74. if (!isset($_SESSION)) {
  75. session_start();
  76. }
  77. $loginFormAction = $_SERVER['PHP_SELF'];
  78. if (isset($_GET['accesscheck'])) {
  79. $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  80. }
  81. if (isset($_POST['inputEmail'])) {
  82. $loginUsername=$_POST['inputEmail'];
  83. $password=$_POST['inputPassword'];
  84. $MM_fldUserAuthorization = "";
  85. $MM_redirectLoginSuccess = "dashboard.php";
  86. $MM_redirectLoginFailed = "login.php";
  87. $MM_redirecttoReferrer = true;
  88. mysql_select_db($database_neticketing, $neticketing);
  89. $LoginRS__query=sprintf("SELECT user_email, user_password FROM user_info WHERE user_email=%s AND user_password=%s",
  90. GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  91. $LoginRS = mysql_query($LoginRS__query, $neticketing) or die(mysql_error());
  92. $loginFoundUser = mysql_num_rows($LoginRS);
  93. if ($loginFoundUser) {
  94. $loginStrGroup = "";
  95. if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  96. //declare two session variables and assign them
  97. $_SESSION['MM_Username'] = $loginUsername;
  98. $_SESSION['MM_UserGroup'] = $loginStrGroup;
  99. if (isset($_SESSION['PrevUrl']) && true) {
  100. $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  101. }
  102. header("Location: " . $MM_redirectLoginSuccess );
  103. }
  104. else {
  105. header("Location: ". $MM_redirectLoginFailed );
  106. }
  107. }
  108. ?>
  109. <!DOCTYPE html>
  110. <html>
  111. <head>
  112. <title>Login page</title>
  113. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  114. <!-- Bootstrap -->
  115. <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
  116. <link href="css/main_style.css" media="screen" rel="stylesheet"
  117. type="text/css">
  118. <link href="images/favicon.ico" rel="icon" type="image/icon" />
  119. </head>
  120. <body>
  121. <!-------------------HEADER START---------------------->
  122. <?php include('include/header.php');?>
  123. <!-------------------HEADER END---------------------->
  124. <!-------------------BODY START---------------------->
  125. <div id="signup_body" class="account_body" style="padding-top: 0px;">
  126. <div id="tabs">
  127. <!--main menu-->
  128. <?php include('include/navigation.php');?>
  129. <!--main menu-->
  130. <!-- DIV start for Dashboard -->
  131. <div id="trainroute" style="margin-top: 30px;">
  132. <div id="train_route_div">
  133. <form ACTION="<?php echo $loginFormAction; ?>" METHOD="POST" name="myLoginForm" class="form-horizontal">
  134. <fieldset>
  135. <legend>Login Form</legend>
  136. <div class="control-group">
  137. <label class="control-label" for="inputEmail">Email</label>
  138. <div class="controls">
  139. <input type="email" name="inputEmail" id="inputEmail" placeholder="Email"
  140. required>
  141. </div>
  142. </div>
  143. <div class="control-group">
  144. <label class="control-label" for="inputPassword">Password</label>
  145. <div class="controls">
  146. <input type="password" name="inputPassword" id="inputPassword"
  147. placeholder="Password" required>
  148. </div>
  149. </div>
  150. <div class="control-group">
  151. <div class="controls">
  152. <input type="submit" class="btn"></button><p></P>
  153. <p>Don't Have an Account?<a href="registration.php"> Sign Up Here</a></p>
  154. </div>
  155. </div>
  156. </fieldset>
  157. </form>
  158. </div>
  159. </div>
  160. <!-- DIV end for Dashboard -->
  161. </div>
  162. </div>
  163. <!-------------------FOOTER START---------------------->
  164. <?php include('include/footer.php');?>
  165. <!-------------------FOOTER END---------------------->
  166. </body>
  167. </html>