Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3. include('config.php');
  4. session_start();
  5. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  6. $user = mysqli_real_escape_string($conn, $_POST['user']);
  7. $pass = mysqli_real_escape_string($conn, $_POST['pass']);
  8. $pass = md5($password);
  9. $_SESSION['last_time'] = time();
  10. $sql = "SELECT * FROM cliente WHERE user='$user' AND '$pass'";
  11. $query = mysqli_query($conn, $sql);
  12. $res = mysqli_num_rows($query);
  13. var_dump($user);
  14. var_dump($pass);
  15. if ($res === 1) {
  16. header("Location: welcome.php");
  17. } else {
  18. echo "Usuario e/ou senha inválidos!";
  19. }
  20. }
  21. ?>
  22.  
  23.  
  24. <html>
  25. <head>
  26. <title>Sessão de Login</title>
  27. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
  28. <link rel="stylesheet" type="text/css" href="login.css">
  29. </head>
  30. <body>
  31. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  32. <div class = 'container'>
  33. <div class="form-group">
  34. <label for="exampleInputEmail1">Login</label>
  35. <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Digite seu Login" name="user">
  36.  
  37. </div>
  38. <div class="form-group">
  39. <label for="exampleInputPassword1">Password</label>
  40. <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Digite sua senha" name="pass">
  41. </div>
  42. <div class="form-check">
  43. <input type="checkbox" class="form-check-input" id="exampleCheck1">
  44. <label class="form-check-label" for="exampleCheck1">Check me out</label>
  45. </div>
  46. <input type="submit" name="user" value="Logar">
  47. <!--<a href="index.php">Home</a>-->
  48. </div>
  49. </form>
  50. <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  51. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  52. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
  53. </body>
  54. </html>
  55.  
  56. <?php
  57. //Database Connection
  58. $servername = "localhost";
  59. $username = "root";
  60. $password = "admin";
  61. $db="website";
  62. //Check Connection
  63. $conn = new mysqli($servername, $username, $password, $db);
  64. if(!$conn){
  65. die ("Error on the Connection" . $conn->connect_error);
  66. }
  67. ?>
  68.  
  69. <?php
  70. include'config.php';
  71. ?>
  72. <!doctype html>
  73. <html>
  74. <head>
  75. <meta charset="UTF-8">
  76. <title>Bem vindo à area administrativa</title>
  77. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
  78. </head>
  79. <body>
  80. <h1 align="center">BEM VINDO!</h1>
  81. <div class="container">
  82. <div class="alert alert-primary" role="alert">
  83. Você se logou à area administrativa!
  84. </div>
  85.  
  86. <form name="admin" method="POST">
  87. <div class="form-group">
  88. <label for="formGroupExampleInput">ID</label>
  89. <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Insira o ID aqui" name="id">
  90. </div>
  91. <div class="form-group">
  92. <label for="formGroupExampleInput2">Nome</label>
  93. <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Nome" name="nome">
  94. </div>
  95. <div class="form-group">
  96. <label for="formGroupExampleInput2">Sobrenome</label>
  97. <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Sobrenome" name="sobrenome">
  98. <div class="form-group">
  99. <label for="formGroupExampleInput2">Email</label>
  100. <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Email" name="email">
  101. </div>
  102. <div class="form-group">
  103. <label for="formGroupExampleInput2">Telefone</label>
  104. <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Telefone" name="telefone">
  105. </div>
  106. <div class="form-group">
  107. <label for="formGroupExampleInput2">Celular</label>
  108. <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Celular" name="celular">
  109. </div>
  110. </div>
  111. <input type="submit" class="btn btn-info" name="submit" value="Listar">
  112. <input type="submit" class="btn btn-secondary" name="submit2" value="Buscar">
  113. <input type="submit" class="btn btn-warning" name="submit3" value="Excluir">
  114. <input type="submit" class="btn btn-danger" name="submit4" value="Atualizar">
  115. </form>
  116.  
  117. </div>
  118. <p align="center"><a href="logout.php">Logout</a></p>
  119.  
  120.  
  121. <?php
  122.  
  123. $txtGet = filter_input_array(INPUT_POST, FILTER_DEFAULT);
  124. if(isset($_POST["submit"]))
  125. {
  126. $res=mysqli_query($link, "select * from cliente");
  127. echo "<table border='2' align='center'>";
  128. echo"<tr>";
  129. echo"<th>"; echo "ID"; echo"</th>";
  130. echo"<th>"; echo "Nome"; echo"</th>";
  131. echo"<th>"; echo "Sobrenome"; echo"</th>";
  132. echo"<th>"; echo "Email"; echo"</th>";
  133. echo"<th>"; echo "Telefone"; echo"</th>";
  134. echo"<th>"; echo "Celular"; echo"</th>";
  135. echo"</tr>";
  136. while($row=mysqli_fetch_array($res)){
  137. echo"<tr>";
  138. echo"<td>"; echo $row["id"]; echo"</td>";
  139. echo"<td>"; echo $row["nome"]; echo"</td>";
  140. echo"<td>"; echo $row["sobrenome"]; echo"</td>";
  141. echo"<td>"; echo $row["email"]; echo"</td>";
  142. echo"<td>"; echo $row["telefone"]; echo"</td>";
  143. echo"<td>"; echo $row["celular"]; echo"</td>";
  144. echo"</tr>";
  145. }
  146. echo "</table>";
  147. }
  148. if(!empty(isset($_POST["submit2"])))
  149. {
  150. //$res=mysqli_query($link, "select * from cliente where id='$_POST[id]' or nome='$_POST[nome]' or sobrenome='$_POST[sobrenome]' or email='$_POST[email]' or telefone='$_POST[telefone]' or celular='$_POST[celular]'");
  151. echo "<table border='2' align='center'>";
  152. echo"<tr>";
  153. echo"<th>"; echo "id"; echo"</th>";
  154. echo"<th>"; echo "nome"; echo"</th>";
  155. echo"<th>"; echo "sobrenome"; echo"</th>";
  156. echo"<th>"; echo "email"; echo"</th>";
  157. echo"<th>"; echo "telefone"; echo"</th>";
  158. echo"<th>"; echo "celular"; echo"</th>";
  159. echo"</tr>";
  160. while($row=mysqli_fetch_array($res)){
  161. echo"<tr>";
  162. echo"<td>"; echo $row["id"]; echo"</td>";
  163. echo"<td>"; echo $row["nome"]; echo"</td>";
  164. echo"<td>"; echo $row["sobrenome"]; echo"</td>";
  165. echo"<td>"; echo $row["email"]; echo"</td>";
  166. echo"<td>"; echo $row["telefone"]; echo"</td>";
  167. echo"<td>"; echo $row["celular"]; echo"</td>";
  168. echo"</tr>";
  169. }
  170. echo "</table>";
  171.  
  172. }
  173.  
  174. if(isset($_POST["submit3"]))
  175. {
  176. mysqli_query($link, "delete from cliente where id='$_POST[id]'");
  177. echo "Exclusão realizada com sucesso!";
  178. }
  179. if(isset($_POST["submit4"])){
  180. mysqli_query($link, "update cliente set nome='$_POST[nome]', sobrenome='$_POST[sobrenome]', email='$_POST[email]', telefone='$_POST[telefone]', celular='$_POST[celular]' where id ='$_POST[id]'");
  181. }
  182. ?>
  183.  
  184.  
  185.  
  186.  
  187.  
  188. <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin = "anonymous"></script>
  189. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  190. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
  191. </body>
  192. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement