Nerviie

Registar

May 26th, 2019
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.27 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Registo</title>
  5.         <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  6.         <style type="text/css">
  7.             #principal{
  8.                 margin: auto;
  9.                 width: 23%;
  10.                 border: 3px solid #0099ff;
  11.                 padding: 10px;
  12.                 border-radius: 5px;
  13.                 margin-top: 50px;
  14.                 margin-left: 200px;
  15.                 float: left;
  16.             }
  17.             body{
  18.                 background-color: white;
  19.                 color: black;
  20.                 font-family: cursive;
  21.             }
  22.             #registo{
  23.                 cursor: pointer;
  24.                 border-radius: 10px;
  25.                 width: 100%;
  26.                 height: 100%;
  27.             }
  28.             legend{
  29.                 font-size: 30px;
  30.                 font-family: Rockwell;
  31.             }
  32.             img{
  33.                 float: left;
  34.                 width: 30%;
  35.                 height: 25%;
  36.                 border-radius: 10px;
  37.                 border: 3px solid #0099ff;
  38.                 margin-left: 10%;
  39.                 margin-top: 5%;
  40.                 cursor: pointer;
  41.             }
  42.             img:hover {
  43.                 /* Start the shake animation and make the animation last for 0.5 seconds */
  44.                 animation: shake 0.5s;
  45.                 /* When the animation is finished, start again */
  46.                 animation-iteration-count: infinite;
  47.             }
  48.             @keyframes shake {
  49.                 0% { transform: translate(1px, 1px) rotate(0deg); }
  50.                 10% { transform: translate(-1px, -2px) rotate(-1deg); }
  51.                 20% { transform: translate(-3px, 0px) rotate(1deg); }
  52.                 30% { transform: translate(3px, 2px) rotate(0deg); }
  53.                 40% { transform: translate(1px, -1px) rotate(1deg); }
  54.                 50% { transform: translate(-1px, 2px) rotate(-1deg); }
  55.                 60% { transform: translate(-3px, 1px) rotate(0deg); }
  56.                 70% { transform: translate(3px, 1px) rotate(-1deg); }
  57.                 80% { transform: translate(-1px, -1px) rotate(1deg); }
  58.                 90% { transform: translate(1px, 2px) rotate(0deg); }
  59.                 100% { transform: translate(1px, -2px) rotate(-1deg); }
  60.             }
  61.             .ok{
  62.                 background-color: #00ff00;
  63.                 color: white;
  64.                 border-radius: 10px;
  65.                 width: 100%;
  66.                 height: 30px;
  67.                 text-align: center;
  68.             }
  69.             .alert{
  70.                 background-color: #ff0000;
  71.                 color: white;
  72.                 border-radius: 10px;
  73.                 width: 100%;
  74.                 height: 50px;
  75.                 text-align: center;
  76.             }
  77.         </style>
  78.     </head>
  79. <body>
  80.     <?php
  81.         $bd_host="localhost";
  82.         $bd_user="root";
  83.         $bd_password="";
  84.         $bd_database="website";
  85.        
  86.         $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
  87.  
  88.         if ($ms->connect_error) {
  89.             die('Erro: ('. $ms->connect_errno .') '. $ms->connect_error);
  90.         }
  91.  
  92.         $msg="";
  93.  
  94.         if (isset($_POST["registar"])) {
  95.             if($_POST["mail"]=="" || $_POST["password"]=="" || $_POST["nome"]==""){
  96.                 $msg="<div class='alert'>Tem de completar a informação!</div>";
  97.             }
  98.             else{
  99.                 $query = "INSERT INTO login(mail,password,nome) VALUES(?,?,?)";
  100.                 $statement = $ms->prepare($query);
  101.                 $statement->bind_param('sss',   $_POST["mail"],
  102.                                                 $_POST["password"],
  103.                                                 $_POST["nome"]);
  104.                 if ($statement->execute() && $statement->affected_rows>0){
  105.                     $msg= "<div class='ok'>Carregue no botão e faça Login</div>";
  106.                 }
  107.                 else{
  108.                     $msg= "<div class='alert'>Já Foi inserido esse E-mail!</div>";
  109.                 }
  110.                 $statement->close();
  111.             }
  112.         }
  113.     ?>
  114.     <img src="pc.jpg" class="img-fluid" alt="Responsive image">
  115.     <div id="principal">
  116.         <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
  117.             <legend>Registo</legend>
  118.             <label>Nome:</label><input class="form-control mr-sm-2" type="text" name="nome" placeholder="Nome" aria-label="Search"><br>
  119.             <label>Email: </label><input class="form-control mr-sm-2" type="email" name="mail" placeholder="E-mail" aria-label="Search" autocomplete="on"><br>
  120.             <label>Password:</label><input class="form-control mr-sm-2" type="password" name="password" placeholder="Password" aria-label="Search"><br>
  121.             <br>
  122.             <button type="submit" class="btn btn-outline-info" name="registar" id="registo">Registar</button>
  123.             <br>
  124.         </form>
  125.         <br>
  126.         <?php
  127.             echo "$msg";
  128.         ?>
  129.         <br>
  130.         <button class="btn btn-outline-primary" type="submit" id="butao" onclick="window.open('index.php');">Visitar WebSite</button>
  131.     </div>
  132. </body>
  133. </html>
Advertisement
Add Comment
Please, Sign In to add comment