Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <div id="NavBar">
  2. <nav>
  3. <ul>
  4. <li><a href="Home.php">Home</a></li>
  5. <?php
  6. if(isset($_SESSION['Username'])):?>
  7.  
  8. <li> <a href="#"><?php echo $_SESSION['Username'];?></a></li>
  9. <?php
  10.  
  11. else:?>
  12.  
  13. <li><a href="Login2.php">Student Login</a></li>
  14. <?php
  15. endif;
  16.  
  17. ?>
  18. <li><a href="Candidate Profile.php">Candidates Profile</a></li>
  19. <li><a href="Admin.php">Admin</a></li>
  20. </ul>
  21. </nav>
  22. </div>
  23.  
  24. define('DB_USER','root');
  25. define('DB_PASSWORD','password007');
  26.  
  27. $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
  28. $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
  29. /*
  30. $ID = $_POST['user'];
  31. $Password = $_POST['pass'];
  32. */
  33. function SignIn()
  34. {
  35. session_start(); //starting the session for user profile page
  36. if(!empty($_POST['UserName'])) //checking the 'user' name which is from Sign-In.html, is it empty or have some text
  37. {
  38. $query = mysql_query("SELECT Username, Password, voting_status FROM voters where Username = '$_POST[UserName]' AND Password = '$_POST[password]'") or die(mysql_error());
  39. $row = mysql_fetch_array($query) or die(mysql_error());
  40. if(!empty($row['Username']) AND !empty($row['Password']) AND $row['voting_status']=='a')
  41. {
  42.  
  43. $_SESSION['Username'] = $row['Password'];
  44. header("location:Result.php");
  45.  
  46. }
  47. elseif(!empty($row['Username']) AND !empty($row['Password']) AND $row['voting_status']=='b')
  48. {
  49. $_SESSION['Username'] = $row['Password'];
  50. header("location:Voted User.php");
  51. }
  52. }
  53. }
  54. if(isset($_POST['submit']))
  55. {
  56. SignIn();
  57. }
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement