11-23-2016, 09:09 AM
Hey,
I cannot seem to get that sending an email to a user right.
I'm using this form:
<pre></pre>
Any idea what im doing wrong?
I cannot seem to get that sending an email to a user right.
I'm using this form:
<pre>
Code:
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$from = $user->data()->email['email'];
$to = $thatUser->email;
$subject = 'Message from Local Positivity Finder';
$body ="From: $name\n E-Mail: $email\n Message: $message\n";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Please enter your message';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Your anti-spam is incorrect';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body)) {
Redirect::to($us_url_root.'users/contact_success.php');
} else {
Redirect::to($us_url_root.'users/contact_error.php');
}
}
}
?>
Any idea what im doing wrong?