PHP - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of PHP .php
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <title>Sistema de Login </title>
- <meta charset="UTF-8" />
- <!-- Estilos da Index.php -->
- <style type="text/css">
- body{
- background: linear-gradient(45deg, #f0f9ff 10%, #cbebff 47%, #a1dbff 100%);
- }
- div.global{
- width: 40%;
- height: auto;
- background-color: #fff;
- border: 1px solid #606060;
- padding: 50px;
- box-shadow: 0px 0px 10px #000;
- margin-top: 10%;
- margin-left: auto;
- margin-right: auto;
- }
- input[type='text'], input[type='password']{
- width: 300px;
- height: 25px;
- border: solid 1px #606060;
- border-radius: 5px;
- }
- input[type='password']{
- margin-left: 10px;
- }
- input[type='submit']{
- width: 150px;
- }
- </style>
- </head>
- <body>
- <div class="global">
- <form name="" method="post" action="">
- <label>Usuário: <input type="text" name="user" /></label><br /><br />
- <label>Senha: <input type="password" name="pass" /></label><br /><br />
- <input type="submit" name="submit" value="Logar!" />
- </form>
- <?php
- $user = @$_REQUEST['user'];
- $pass = @$_REQUEST['pass'];
- $submit = @$_REQUEST['submit'];
- $user1 = 'gabi';
- $pass1 = '12345';
- $user2 = 'maythe';
- $pass2 = '54321';
- if($submit){
- /* Se o campo usuário ou senha estiverem vazios geramos um alerta */
- if($user == "" || $pass == ""){
- echo "<script:alert('Por favor, preencha todos os campos!');</script>";
- }
- /* Caso o campo usuario e senha não
- *estejam vazios vamos testar se o usuário e a senha batem
- *iniciamos uma sessão e redirecionamos o usuário para o painel */
- else{
- if(($user == $user1 && $pass == $pass1) || ($user == $user2 && $pass == $pass2)){
- session_start();
- $_SESSION['usuario']=$user;
- $_SESSION['senha']=$pass;
- header("Location: painel.php");
- }
- /* Se o usuario ou a senha não batem alertamos o usuario */
- else{
- echo "<script>alert('Usuário e/ou senha inválido(s), Tente novamente!');</script>";
- }
- }
- }
- ?>
- </div>
- </body>
- </html