Basic key system

0

What I want to do is a small system in php / mysql. I want to manually sign the keys via mysql and if the guy activates the site the key he will receive an email with some texts.

Can anyone help me?

I have tried to do: PHP:

<?php
//====================================================
//Mysql
$servername = "localhost";
$username = "db";
$password = "teste";

$conn = mysqli_connect($servername, $username, $password, "db");
$conn = new mysqli($servername, $username, $password);

$sql = mysqli_query($conn, "SELECT * FROM tabela WHERE key = '{$key}'");
$result = $conn->query("SELECT * FROM tabela WHERE key = '{$key}'");

$num_rows = $result->num_rows;

if (isset($_POST['BTEnvia'])) { 

//Variaveis de POST, Alterar somente se necessário 
//====================================================
$Key = $_POST['Key'];
$email = $_POST['email'];
$telefone = $_POST['telefone']; 
$mensagem = $_POST['mensagem'];
//====================================================

//REMETENTE --> ESTE EMAIL TEM QUE SER VALIDO DO DOMINIO
//==================================================== 
$email_remetente = "contato@peca"; // deve ser uma conta de email do seu dominio 
$redirect = "ativacao.php";
//====================================================

//Configurações do email, ajustar conforme necessidade
//==================================================== 
$email_destinatario = "[email protected]"; // pode ser qualquer email que receberá as mensagens
$email_reply = "$email"; 
$email_assunto = "Nova Ativação de key " .$Key.""; // Este ser&aacute; o assunto da mensagem
//====================================================

//Monta o Corpo da Mensagem
//====================================================
$email_conteudo = "Key = $Key \n"; 
$email_conteudo .= "Email = $email \n";
//====================================================

//Seta os Headers (Alterar somente caso necessario) 
//==================================================== 
$email_headers = implode ( "\n",array ( "From: $email_remetente", "Reply-To: $email_reply", "Return-Path: $email_remetente","MIME-Version: 1.0","X-Priority: 3","Content-Type: text/html; charset=UTF-8" ) );
//====================================================

//Enviando o email 
//==================================================== 
if (mail ($email_destinatario, $email_assunto, nl2br($email_conteudo), $email_headers)){  
  header("Location: $redirect");

            exit;
                } 
        else{ 
                echo "</b>Falha no envio do E-Mail!</b>"; } 
//====================================================
} 
?>

Html:                            

 <!-- Latest compiled and minified CSS -->
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

 <!-- Optional theme -->
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

 <!-- Latest compiled and minified JavaScript -->
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<nav class="navbar navbar-inverse bg-inverse">
<a class="navbar-brand" href="#">Ativa&ccedil;&atilde;o de key</a>

</nav>
<title>&raquo Ativa&ccedil;&atilde;o de key </title>
</head>
<body>
<center>
<h1> Ativa&ccedil;&atilde;o de key </h1>
<form action="<? $PHP_SELF; ?>" method="POST"> 
<p> 
<h2> Preencha todos os dados corretamentes, o email da conta ser&aacute; transferido pro email que voc&ecirc; colocar aqui.</h2>
    Key:<br /> 
    <input type="text" class="form-control" size="30" name="Key"> 
</p>   
<p> 
    E-mail:<br /> 
    <input type="text" class="form-control" size="30" name="email">     
</p>   
<p> 

<p>
      <input type="submit" class="btn btn-primary" name="BTEnvia" value="Enviar"> 
  <input type="reset" class="btn btn-primary" name="BTApaga" value="Limpar">
    </p>
    </center>
    </body>
     <nav class="navbar navbar-inverse bg-primary">
<a class="navbar-brand" href="#">Lembrando, caso ocorra de voc&ecirc; preenche o email errado, n&atilde;o nos responsabilizaremos.</a>

        

    
asked by anonymous 07.02.2018 / 18:44

0 answers