Advertisement
ElenaR1

index0.php

Jan 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <?php
  2. include_once('connection.php');
  3. include_once('database_table.php');
  4.  
  5.  
  6. $errors=array();
  7. $errors2=array();
  8.  
  9. if($_POST)
  10. {
  11. if (isset($_POST['teacher_formSubmit']))
  12. {
  13. if($_POST['teacher_psw']!='teach12' || $_POST['teacher_fn']!=0)
  14. {
  15. $errors['teacher_psw']="Грешна парола или факултетен номер";
  16. }
  17.  
  18.  
  19. if(count($errors)==0)
  20. {
  21. header("Location: index.php");
  22. exit();
  23. }
  24. }
  25. else
  26. {
  27. $stdent_psw=$_POST['student_psw'];
  28. $fn=$_POST['student_fn'];
  29. $db=new connection();
  30. $db=$db->dbConnect();
  31. $sql="SELECT * from students where password =?";
  32. $st=$db->prepare($sql);
  33. $st->execute([$stdent_psw]);
  34. if($st->rowCount()==0)
  35. {
  36. echo '<span style="color:#FF0000;text-align:center;">Паролата е неправилна или такъв студент не съществува в базата данни. Моля върнете се и попълнете формата отново</span>'.'<br/>';
  37. //$errors2['student_psw']="The password is not correct or there is no such student in the database.";
  38. }
  39. else if ($row=$st->fetch())
  40. {
  41. if($row['fn']!=$fn)
  42. {
  43. echo '<span style="color:#FF0000;text-align:center;">Факултетния номер не съответства на зададената парола. Моля върнете се и попълнете формата отново</span> '.'<br/>';
  44. }
  45. else
  46. {
  47. $object=new DBTable();
  48. $object->show_info($fn);
  49. //header("Location: student.php");
  50. }
  51. }
  52.  
  53. exit();
  54. }
  55. }
  56.  
  57. ?>
  58. <html>
  59. <head>
  60. <meta charset="utf-8">
  61. <link href="style_register.css" rel="stylesheet">
  62. <title>Form to fill</title>
  63. </head>
  64.  
  65. <body>
  66. <img class="imagec" src="su_logo.jpg" style="margin-left:400px; margin-right:40px; margin-top:10px;margin-bottom:10px;" >
  67. <h1>Вход в студентска информационна система</h1>
  68. <p class="para1"> Ако сте учител попълнете следната форма: </p>
  69.  
  70. <div class="container">
  71. <h1>LogIn форма за учител</h1>
  72.  
  73. <form method="POST" target="" style="margin-left:40px; margin-right:40px;">
  74. <p>
  75. <label for="teacher_fn"> </label>
  76. <input type="number" name="teacher_fn" id="teacher_fn" min="0" placeholder='Напишете факултетния си номер' required />
  77. </p>
  78. <p>
  79. <label for="teacher_psw"></label>
  80. <input type="password" name="teacher_psw" id="teacher_psw" placeholder='Въведете парола ' required />
  81. </p>
  82. <p> <?php
  83. if (isset($errors['teacher_psw']))
  84. {
  85. echo $errors['teacher_psw'];
  86. }
  87. ?>
  88. </p>
  89. <input type="submit" name="teacher_formSubmit" value="Потвърди">
  90. </form>
  91. </div>
  92.  
  93. <p class="para1">Ако сте ученик попълнете следната форма: </p>
  94. <div class="container">
  95. <h1>LogIn форма за ученик</h1>
  96. <form method="POST" target="" style="margin-left:40px; margin-right:40px;">
  97. <p>
  98. <label for="student_fn"></label>
  99. <input type="number" name="student_fn" id="student_fn" min="0" placeholder='Напишете факултетния си номер' required />
  100. </p>
  101. <p>
  102. <label for="student_psw"></label>
  103. <input type="password" name="student_psw" id="student_psw" placeholder='Въведете парола ' required />
  104. </p>
  105. <p> <?php
  106. if (isset($errors2['student_psw']))
  107. {
  108. echo $errors2['student_psw'];
  109. }
  110. ?>
  111. </p>
  112. <input type="submit" name="student_formSubmit" value="Потвърди">
  113. </form>
  114. </div>
  115.  
  116.  
  117. </body>
  118.  
  119.  
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement