Guest User

Untitled

a guest
Dec 7th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5.  
  6.  
  7.  
  8. //$valid = $_SESSION['username'];
  9.  
  10.  
  11. if($_SESSION['username'] == true){
  12.  
  13. print_r($_SESSION);
  14.  
  15. $message = "Welcome back dood";
  16.  
  17. echo $message;
  18.  
  19. }
  20. else
  21. {
  22. if(isset($_POST['submit']))
  23. {
  24.  
  25. include 'dbConnect.php';
  26.  
  27. $user = $_POST['username'];
  28. $pass = $_POST['password'];
  29.  
  30.  
  31. $sql = "SELECT event_user_name, event_user_password FROM event_log_in WHERE event_user_name = 'username' AND event_user_password = 'password'";
  32.  
  33. $query = $conn->prepare($sql) or die("<p>SQL String: $sql</p>");
  34.  
  35.  
  36.  
  37. $query->execute()or die("<p>Execution </p>");
  38.  
  39.  
  40.  
  41.  
  42. //$query->store_result();
  43.  
  44. $query->fetch();
  45.  
  46.  
  47.  
  48.  
  49. if ($_SESSION['username'] = true) //If this is a valid user there should be ONE row only
  50. {
  51. //this is a valid user so set your SESSION variable
  52. $message = "Welcome Back!";
  53.  
  54. echo $message;
  55. //Valid User can do the following things:
  56. }
  57. else
  58. {
  59. //error in processing login. Logon Not Found...
  60. $_SESSION['username'] = false;
  61. $message = "Sorry, there was a problem with your username or password. Please try again.";
  62.  
  63. echo $message;
  64. }
  65.  
  66. //$query->close();
  67. //$conn->close();
  68. }
  69. }
  70.  
  71. ?>
  72.  
  73. <html>
  74.  
  75. <head>
  76.  
  77.  
  78. </head>
  79.  
  80.  
  81. <body>
  82.  
  83. <?php
  84.  
  85. print_r($_SESSION);
  86.  
  87. if ($_SESSION['username'] == true) //This is a valid user. Show them the Administrator Page
  88. {
  89.  
  90. //turn off PHP and turn on HTML
  91. ?>
  92. <h3>Presenters Administrator Options</h3>
  93. <p><a href="contactForm1.php">Input New Contact</a></p>
  94. <p><a href="selectEvents.php">List of Contacts</a></p>
  95. <p><a href="logingOut.php">Logout of Contacts Admin System</a></p>
  96.  
  97. <?php
  98. }
  99. else //The user needs to log in. Display the Login Form
  100. {
  101. ?>
  102.  
  103. <form name = "form1" id = "form1" method = "post" action = "loginFile.php">
  104.  
  105. <p>Please enter your username:
  106. <input type = "text" name = "username" id = "username">
  107. </p>
  108. <p>Please enter your password:
  109. <input type = "text" name = "password" id = "password">
  110. </p>
  111.  
  112. <input type = "submit" name = "submit" id = "submit" value = "LOGIN">
  113. </form>
  114.  
  115. <?php //turn off HTML and turn on PHP
  116. }//end of checking for a valid user
  117.  
  118. //turn off PHP and begin HTML
  119. ?>
  120.  
  121. <p>Return to <a href='#'>www.presentationstogo.com</a></p>
  122. </body>
  123.  
  124. </html>
Add Comment
Please, Sign In to add comment