I'm finishing up my project now but can't seem to see where i went wrong on my PHP form. To me everything is correct yet i'm getting an error.
Warning: mail() expects parameter 4 to be string, array given in /customers/f/a/b/webpx.be/httpd.www/sendemail.php on line 15
My php form:
<?php
$name = @trim(stripslashes($_POST['name']));
$email = @trim(stripslashes($_POST['email']));
$message = @trim(stripslashes($_POST['message']));
$to = 'email@email.com';//replace with your email
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
?>
<?php
if ($_POST['submit']) {
if (mail($to, $subject, $message, $headers)) {
echo '<p>Thank you for your Email! We will contact you very soon.</p>';
}
else {
echo '<p>Oops! An error occurred. Try sending your message again.</p>';
}
}
?>
<style type="text/css">
p{text-align:center;font-size:50px;background:#0091a2;margin-top:30px;padding:20px;width:500px;margin:0 auto;color:#fff}
</style>
My HTML:
<form method="post" action="sendemail.php" onsubmit="return validation();">
<div class="row">
<div class="form-group col-md-6">
<input type="text" name="name" class="form-control" placeholder="voornaam + familienaam" required="required">
</div>
<div class="form-group col-md-6">
<input type="email" name="email" class="form-control" placeholder="e-mail" required="required">
</div>
<div class="form-group col-md-12">
<textarea rows="6" name="message" class="form-control" placeholder="Uw boodschap ..." required="required"></textarea>
</div>
<div class="form-group col-md-12">
<button type="submit" class="btn btn-lg btn-dark-bg" data-loading-text="Sending...">Verstuur bericht</button>
</div>
</div>
</form>
The only thing I think that can be wrong is the "to" in my form. Could someone point me in the right direction please?
Thx in advance!