3
I’m setting up a registration system and only need the confirmation part in the email to finish and I’m not able to do this part. I’ve researched tutorials on youtube and tried to apply them to my code, only it doesn’t work, someone could help me ?
<?php
if(isset($_POST['cadastrar']) && $_POST ['cadastrar'] == "register")
{
$nome = $_POST['nome'];
$sobrenome = $_POST['sobrenome'];
$data = $_POST['data'];
$cpf = $_POST['cpf'];
$email = $_POST['email'];
$pais = $_POST['pais'];
$estado = $_POST['estado'];
$login = $_POST['login'];
$senha = $_POST['senha'];
$rsenha = $_POST['rsenha'];
$image = $_FILES['image']['name'];
if(empty($nome) || empty($sobrenome) || empty($data) || empty($cpf) || empty($email) || empty($pais) || empty($estado) || empty($login) || empty($senha) || empty($rsenha) || ($cpf_enviado == false) || (@$emailvalida == false))
{
}else{
$query = "SELECT * FROM cadastro WHERE login = '$login'";
$result = mysql_query($query);
$conta = mysql_num_rows($result);
$busca = mysql_fetch_assoc($result);
if($conta > 0){
echo '<div id="preencha" style="width:200px; position:relative; left:580px; top:-30px; color:#fff; font-size:15px; ">Usuário já cadastrado!</div> ';
}else{
$cadastrar = "INSERT INTO cadastro (nome, sobrenome, data, cpf, email, pais, estado, login, senha, rsenha, image)
VALUES ('$nome', '$sobrenome', '$data', '$cpf', '$email', '$pais', '$estado', '$login', '$senha', '$rsenha', '$image')";
if(mysql_query($cadastrar))
{
$_SESSION['nome'] = $nome;
$_SESSION['sobrenome'] = $sobrenome;
$_SESSION['data'] = $data;
$_SESSION['cpf'] = $cpf;
$_SESSION['email'] = $email;
$_SESSION['pais'] = $pais;
$_SESSION['estado'] = $estado;
$_SESSION['login'] = $login;
$_SESSION['senha'] = $senha;
$_SESSION['rsenha'] = $rsenha;
$_SESSION['image'] = $image;
echo "<script type=\"text/javascript\">window.setTimeout(\"location.href='cadastroRealizado.php';\");</script>";
}
else
{
echo '<div id="preencha" style="width:200px; position:relative; left:580px; top:-30px; color:#fff; font-size:15px; ">Erro ao cadastrar!</div>';
}
$conexaoemail = mysql_query("SELECT * FROM cadastro WHERE nome = '$nome'");
$resultado = mysql_fetch_array($conexaoemail);
$id = $resultado['id'];
$assunto = "Ative sua conta";
$mensagem = "Ative sua conta clicando no link:";
$headers = "[email protected]";
$email = $_POST['email'];
mail($email, $assunto, $mensagem, $headers);
}
}
}
?>
What is the problem you are facing? Your application displays some error when code runs?
– Woss
In case of the problem, I followed this simple tutorial: https://www.youtube.com/watch?v=CqddjTQjJXA&t=906s .
– Diego Magalhães
If you have a video tutorial or better instructions, please let me know, I’m in great need and I want to learn how to do this.
– Diego Magalhães
If the problem is no in the email sending code, try Phpmailer http://answall.com/questions/177812/envio-de-e-mail-com-fun%C3%A7%C3%A3o-mail/177832#177832
– user60252
Check this http://answall.com/questions/40858/como-mail-do-localhost-usando-a-fun%C3%A7%C3%A3o-mail-do-php/40861#40861
– Inkeliz
First you need the following, is your SMTP server active and authenticated with your pop server? example, you can try the Mailgun before sending it to the online server, in which case if it works with Mailgun it might be your server.
– flourigh
Think about using some framework that can help you a lot at this point, one that makes it very easy to send emails is Laravel
– Mateus