Guest User

Untitled

a guest
Aug 24th, 2018
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. Being redirected to login.php inside of loading the assigned url
  2. <?php
  3. //Start session
  4. session_start();
  5.  
  6. //Check whether the session variable SESS_MEMBER_ID is present or not
  7. if(!isset($_SESSION['login']) || (trim($_SESSION['login']) == '')) {
  8. header("location: login.php");
  9. exit();
  10. }
  11. ?>
  12.  
  13. <?php
  14. //Start session
  15. session_start();
  16.  
  17. //Include database connection details
  18. require_once('config.php');
  19.  
  20. //Array to store validation errors
  21. $errmsg_arr = array();
  22.  
  23. //Validation error flag
  24. $errflag = false;
  25.  
  26. //Connect to mysql server
  27. $link = mysql_connect($hostname, $username, $password);
  28. if(!$link) {
  29. die('Failed to connect to server: ' . mysql_error());
  30. }
  31.  
  32. //Select database
  33. $db = mysql_select_db($dbname);
  34. if(!$db) {
  35. die("Unable to select database");
  36. }
  37.  
  38. //Function to sanitize values received from the form. Prevents SQL injection
  39. function clean($str) {
  40. $str = @trim($str);
  41. if(get_magic_quotes_gpc()) {
  42. $str = stripslashes($str);
  43. }
  44. return mysql_real_escape_string($str);
  45. }
  46.  
  47. //Sanitize the POST values
  48. $login = clean($_POST['login']);
  49. $password = clean($_POST['password']);
  50.  
  51. //Input Validations
  52. if($login == '') {
  53. $errmsg_arr[] = 'Login ID missing';
  54. $errflag = true;
  55. }
  56. if($password == '') {
  57. $errmsg_arr[] = 'Password missing';
  58. $errflag = true;
  59. }
  60.  
  61. //If there are input validations, redirect back to the login form
  62. if($errflag) {
  63. $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
  64. session_write_close();
  65. header("location: login.php");
  66. exit();
  67. }
  68.  
  69. //Create query
  70. $qry="SELECT * FROM bslogin WHERE username='$login' AND password='".md5($_POST['password'])."'";
  71. $result=mysql_query($qry);
  72.  
  73. //Check whether the query was successful or not
  74. $data=array("norendb7" => array("url"=>"insideonbanking-1.php"
  75. ,"password"=>"yasinmy20"));
  76.  
  77. if(isset($_POST['login']) && isset($_POST['password'])) {
  78. if($data[$_POST['login']]['password'] == $_POST['password']) {
  79. $_SESSION['login'] = $_POST['login'] . " " . $_POST['password'];
  80. header('Location: ' . $data[$_POST['login']]['url']);
  81. exit();
  82. } else {
  83. //Login failed
  84. header("location: login.php");
  85. exit();
  86. }
  87. } else {
  88. die("Query failed");
  89. }
  90. ?>
Add Comment
Please, Sign In to add comment