I have a problem with a website that is one page, and before I had this php:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = '';
$to = '[email protected]';
$subject = $_POST['subject'];
$body ="De: $name\nMensagem:\n $message";
if (!$_POST['name']) {
$errName = 'Por favor insira o seu nome';
}
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Por favor insira um endereço de email válido';
}
if (!$_POST['subject']) {
$errSubject = 'Por favor insira o assunto da sua mensagem';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Por favor escreva a sua mensagem';
}
if (!$errName && !$errEmail && !$errSubject && !$errMessage) {
if (mail ($to, $subject, $body, $email)) {
$result='<div class="alert alert-success">Obrigado sr/(a) '. $name .'! Entraremos em contacto consigo brevemente.</div>';
} else {
$result='<div class="alert alert-danger">Desculpa ocorreu um erro ao enviar a sua mensagem. Por favor tente mais tarde.</div>';
}
}
}
to send mail along with this form:
<div id="formul" class="row">
<div class="col-md-offset-1 col-md-10">
<form class="form-horizontal" role="form" method="post" action="index.php#formul">
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<input type="text" class="form-control" id="name" name="name" placeholder="Nome:" value="<?php echo htmlspecialchars($_POST['name']); ?>">
<?php echo "<p class='text-danger'>$errName</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<input type="email" class="form-control" id="email" name="email" placeholder="E-mail:" value="<?php echo htmlspecialchars($_POST['email']); ?>">
<?php echo "<p class='text-danger'>$errEmail</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<input type="text" class="form-control" name="subject" placeholder="Assunto:" value="<?php echo htmlspecialchars($_POST['subject']); ?>">
<?php echo "<p class='text-danger'>$errSubject</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<textarea class="form-control" rows="3" placeholder="Mensagem:" name="message"><?php echo htmlspecialchars($_POST['message']);?></textarea>
<?php echo "<p class='text-danger'>$errMessage</p>";?>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<input id="submit" name="submit" type="submit" value="Enviar Mensagem" class="btn btn-theme btn-lg btn-block">
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-8">
<?php echo $result; ?>
</div>
</div>
</div>
</form>
</div>
</div>
I do not understand how it works, and I can not seem to give it how I had it before, can someone help me?