Hello. I am working on a simple script for a form to put on a work in progress website of mine. I
would like to generate the script myself and understand as fully as I can whats happening in the script as I am trying to get to grips with some basic PHP. The website I am working on is online, and I have enabled scripting on the server and selected PHP as my scripting method of choice. This is the script from the form.php I am having trouble with
<?php
// check form has been submitted //
if (isset($_POST['submitted'])) {
// check the fields have been filled in //
if ( !empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) {
// create the variables //
$name = $_POST['name'];
$email = $_POST['email'];
$body = $_POST['comments'];
// make sure body is under 70 characters per line //
$body = wordwrap($body, 70);
ini_set("sendmail-from", {$_POST['email']});
// create the email //
mail('contact@benhobden.com', 'message from benhobden.com', '$body', null, '-f{$email}' );
print 'thankyou $name for getting in touch. I shall reply to you at $email as soon as I can.';
} else {
print 'please be sure to fill out each part.';
}
}
?>
I have been emailed by a guy from the hosting company - whom I wrote to when I first had problems - that my script must meet three requirements:-
1.)The mailto address must be an address on the hosting server, which it is
2.) I must add the ini_set() function. I am confused about this as the mail isnt really coming from an address, just going to an address. From what I read about this function I understood that it set the "frommail" address?
3.) I need to add the "-f" parameter as a fifth parameter inside the mail() function. I am unsure if the syntax I have used to do this is correct.
Can anybody see any problems within the script above why I might be getting errors?