Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- include('config.php');
- session_start();
- if ($_SERVER['REQUEST_METHOD'] == "POST") {
- $user = mysqli_real_escape_string($conn, $_POST['user']);
- $pass = mysqli_real_escape_string($conn, $_POST['pass']);
- $pass = md5($password);
- $_SESSION['last_time'] = time();
- $sql = "SELECT * FROM cliente WHERE user='$user' AND '$pass'";
- $query = mysqli_query($conn, $sql);
- $res = mysqli_num_rows($query);
- var_dump($user);
- var_dump($pass);
- if ($res === 1) {
- header("Location: welcome.php");
- } else {
- echo "Usuario e/ou senha inválidos!";
- }
- }
- ?>
- <html>
- <head>
- <title>Sessão de Login</title>
- <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">
- <link rel="stylesheet" type="text/css" href="login.css">
- </head>
- <body>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
- <div class = 'container'>
- <div class="form-group">
- <label for="exampleInputEmail1">Login</label>
- <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Digite seu Login" name="user">
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Password</label>
- <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Digite sua senha" name="pass">
- </div>
- <div class="form-check">
- <input type="checkbox" class="form-check-input" id="exampleCheck1">
- <label class="form-check-label" for="exampleCheck1">Check me out</label>
- </div>
- <input type="submit" name="user" value="Logar">
- <!--<a href="index.php">Home</a>-->
- </div>
- </form>
- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- <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>
- <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>
- </body>
- </html>
- <?php
- //Database Connection
- $servername = "localhost";
- $username = "root";
- $password = "admin";
- $db="website";
- //Check Connection
- $conn = new mysqli($servername, $username, $password, $db);
- if(!$conn){
- die ("Error on the Connection" . $conn->connect_error);
- }
- ?>
- <?php
- include'config.php';
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Bem vindo à area administrativa</title>
- <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">
- </head>
- <body>
- <h1 align="center">BEM VINDO!</h1>
- <div class="container">
- <div class="alert alert-primary" role="alert">
- Você se logou à area administrativa!
- </div>
- <form name="admin" method="POST">
- <div class="form-group">
- <label for="formGroupExampleInput">ID</label>
- <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Insira o ID aqui" name="id">
- </div>
- <div class="form-group">
- <label for="formGroupExampleInput2">Nome</label>
- <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Nome" name="nome">
- </div>
- <div class="form-group">
- <label for="formGroupExampleInput2">Sobrenome</label>
- <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Sobrenome" name="sobrenome">
- <div class="form-group">
- <label for="formGroupExampleInput2">Email</label>
- <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Email" name="email">
- </div>
- <div class="form-group">
- <label for="formGroupExampleInput2">Telefone</label>
- <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Telefone" name="telefone">
- </div>
- <div class="form-group">
- <label for="formGroupExampleInput2">Celular</label>
- <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Pesquisar por Celular" name="celular">
- </div>
- </div>
- <input type="submit" class="btn btn-info" name="submit" value="Listar">
- <input type="submit" class="btn btn-secondary" name="submit2" value="Buscar">
- <input type="submit" class="btn btn-warning" name="submit3" value="Excluir">
- <input type="submit" class="btn btn-danger" name="submit4" value="Atualizar">
- </form>
- </div>
- <p align="center"><a href="logout.php">Logout</a></p>
- <?php
- $txtGet = filter_input_array(INPUT_POST, FILTER_DEFAULT);
- if(isset($_POST["submit"]))
- {
- $res=mysqli_query($link, "select * from cliente");
- echo "<table border='2' align='center'>";
- echo"<tr>";
- echo"<th>"; echo "ID"; echo"</th>";
- echo"<th>"; echo "Nome"; echo"</th>";
- echo"<th>"; echo "Sobrenome"; echo"</th>";
- echo"<th>"; echo "Email"; echo"</th>";
- echo"<th>"; echo "Telefone"; echo"</th>";
- echo"<th>"; echo "Celular"; echo"</th>";
- echo"</tr>";
- while($row=mysqli_fetch_array($res)){
- echo"<tr>";
- echo"<td>"; echo $row["id"]; echo"</td>";
- echo"<td>"; echo $row["nome"]; echo"</td>";
- echo"<td>"; echo $row["sobrenome"]; echo"</td>";
- echo"<td>"; echo $row["email"]; echo"</td>";
- echo"<td>"; echo $row["telefone"]; echo"</td>";
- echo"<td>"; echo $row["celular"]; echo"</td>";
- echo"</tr>";
- }
- echo "</table>";
- }
- if(!empty(isset($_POST["submit2"])))
- {
- //$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]'");
- echo "<table border='2' align='center'>";
- echo"<tr>";
- echo"<th>"; echo "id"; echo"</th>";
- echo"<th>"; echo "nome"; echo"</th>";
- echo"<th>"; echo "sobrenome"; echo"</th>";
- echo"<th>"; echo "email"; echo"</th>";
- echo"<th>"; echo "telefone"; echo"</th>";
- echo"<th>"; echo "celular"; echo"</th>";
- echo"</tr>";
- while($row=mysqli_fetch_array($res)){
- echo"<tr>";
- echo"<td>"; echo $row["id"]; echo"</td>";
- echo"<td>"; echo $row["nome"]; echo"</td>";
- echo"<td>"; echo $row["sobrenome"]; echo"</td>";
- echo"<td>"; echo $row["email"]; echo"</td>";
- echo"<td>"; echo $row["telefone"]; echo"</td>";
- echo"<td>"; echo $row["celular"]; echo"</td>";
- echo"</tr>";
- }
- echo "</table>";
- }
- if(isset($_POST["submit3"]))
- {
- mysqli_query($link, "delete from cliente where id='$_POST[id]'");
- echo "Exclusão realizada com sucesso!";
- }
- if(isset($_POST["submit4"])){
- 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]'");
- }
- ?>
- <script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin = "anonymous"></script>
- <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>
- <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>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement