Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. <?php
  2. session_start();
  3. ?>
  4. <html>
  5. <head>
  6. <link href="logdes.css" rel="stylesheet">
  7. </head>
  8. <body>
  9. <div id="box">
  10. <p id="p">Welcome to E-Voting</p>
  11. <form>
  12. <table width=40% align="center" id="tw">
  13. <tr><td>Username:</td><td><input type="text" name="t1"></td></tr>
  14. <tr><td>Password:</td><td><input type="password" name="t2"></td></tr>
  15. <tr><td colspan="2" id="td"><input type="submit" value="Login" name="b1"> </td></tr>
  16. </table>
  17. </form>
  18. </div>
  19. </body>
  20. </html>
  21. <?php
  22. if(isset($_REQUEST['b1']))
  23. {
  24. $k=$_REQUEST["t1"];
  25. $q=$_REQUEST["t2"];
  26. mysql_connect('localhost','root','');
  27. mysql_select_db('project');
  28. $a="select * from login where Username='$k' and password='$q'";
  29. $rs=mysql_query($a);
  30. if(mysql_num_rows($rs)>0)
  31. {
  32. $_SESSION['username1']=$k;
  33. $_SESSION['password1']=$q;
  34. while($row=mysql_fetch_array($rs))
  35. {
  36. if($row['val']==1)
  37. header("location: adminportal.php");
  38. else
  39. header("location: userportal.php");
  40. }
  41. }
  42. else
  43. {
  44. echo"No record found!";
  45. }
  46. }
  47. ?>
  48.  
  49. <?php
  50. session_start();
  51. if(!isset($_SESSION['username1']))
  52. {
  53. header("location: voterlogin.php");
  54. }
  55. else
  56. {
  57. $n=$_SESSION['username1'];
  58. $q=$_SESSION['password1'];
  59. echo"Welcome $n";
  60. }
  61. ?>
  62. <html>
  63. <head>
  64. <link href="logdes.css" rel="stylesheet">
  65. </head>
  66. <body>
  67. <div id="box">
  68. <p id="z">Voter's Portal</p>
  69. <form>
  70. <table width=50% align="center" id="tw">
  71. <tr><td><a href="caninfo.php" class="f">List of Election Candidates</a></td> </tr>
  72. <tr><td><a href="votenow.php" class="f" id="f1">Vote Now</a></td></tr>
  73. <tr><td><a href="viewresults.php" class="f" id="f2">View Results</a></td></tr>
  74. </table>
  75. </form>
  76. </div>
  77. </body>
  78. </html>
  79.  
  80. <?php
  81. session_start();
  82. if(isset($_SESSION['username']))
  83. {
  84. $u=$_SESSION['username'];
  85. $p=$_SESSION['password'];
  86. destroy_session_and_data();
  87. echo" You have been logged out.<br>Click <a href='index.php'>here</a> to return to the home page.";
  88. }
  89. else if(isset($_SESSION['username1']))
  90. {
  91. $k=$_SESSION['username1'];
  92. $q=$_SESSION['password1'];
  93. destroy_session_and_data();
  94. echo" You have been logged out.<br>Click <a href='index.php'>here</a> to return to the home page.";
  95. }
  96. function destroy_session_and_data()
  97. {
  98. $_SESSION = array();
  99. setcookie(session_name(), '' , time()-2592000, '/');
  100. session_destroy();
  101. }
  102. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement