E-mail Notice/Report

Asked

Viewed 33 times

-1

Hello! I’m a beginner and I’m practicing, but PHP don’t know almost nd. I’m looking to create a kind of email warning. Containing the title, chapter number and content chosen by the select. I tried to do by sending normal e-mai, but could not.

body {
    margin: 0;
    font-family: "Tahoma";
}

.reporte {
    background-color: #ffffff;
    width: 400px;
    text-align: center;
    border-radius: 10px;
    position: fixed;
    z-index: 10001;
    top: 50%;
    left: 50%;
    margin-left: -230px;
    margin-top: -150px;
}

.campo h2 {
    display: inline-block;
    color: #a42f2f;
}

select, input {
    margin-bottom: 10px;
    outline: 0;
}

label {
    font-size: 14px;
    color: #888888;
}

select, input {
    border: none;
    background-color: #e2e2e2;
    padding: 5px 10px;
    border-radius: 5px;
}

select {
    color: #888888;
}

#btn {
    background-color: #ffffff;
    border: 2px solid #a42f2f;
    color: #a42f2f;
    padding: 6px 15px;
    cursor: pointer;
    margin-bottom: 10px;
}

#btn:hover {
    background-color: #a42f2f;
    color: #ffffff;
}

#opacidade {
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    position: fixed;
    z-index: 10000;
}
<div class="reporte">
        <div class="campo">

            <h2>Informe o Erro</h2>
            <form action="" method="post">

                <select name="opcoes" required>
  <option value="1">Sem páginas</option>
  <option value="2">Capítulo repetido</option>
  <option value="3">Páginas embaralhadas</option>
  <option value="4">Falta página</option>
  <option value="5">Páginas repetidas</option>
</select></br>
                <label for="titulo2">Digite o nome:</label></br>
                <input type="text" name="titulo2" id="titulo2" placeholder="Título..." required></br>

                <label for="capitulo2">Digite o número:</label></br>
                <input type="text" name="capitulo2" id="capitulo2" placeholder="01..." required></br>
                <input type="submit" value="Enviar" id="btn">
            </form>

        </div>
    </div>
    <div id="opacidade"></div>

  • You said you tried to do it, but where’s the code you tried? Come too [mcve].

  • So Francisco, I tried with this code here: https://www.kinghost.com.br/wiki/artigo/formphp/

1 answer

1


Use the function mail():

<?php
$opt = $_POST['opcoes'];
$titulo = $_POST['titulo2'];
$cap = $_POST['capitulo2'];

//Pessoa que vai receber o email
$destinatario = "[email protected]";

//Assunto do email
$assunto = "Sobre o erro: $opcoes";

//Corpo do email
$mensagem =
"
Referente ao erro: $opcoes
Titulo: $titulo
Capitulo: $cap
";

//Envio do email
mail($destinatario, $assunto, $mensagem, "From: [email protected]"."\r\n"."CC: [email protected]");
?>

Don’t forget to set up php.ini!

Behold that, if you have more questions. Or official documentation.

  • Francisco, it worked mt thanks. But there was a mistake... all the time q I give F5 on the page it resends.

  • This is not a mistake, it’s right. What you should do is not let it happen through some if.

  • I did. I created an If to send blank n send, but when I give F5 after sending one. It sends.

  • Put that condition on your if: if(isset($_POST['opcoes']))

  • Don’t forget to give your upvote and mark the answer as correct!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.