hobden81 Posted May 20, 2009 Report Share Posted May 20, 2009 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? Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 20, 2009 Report Share Posted May 20, 2009 It would help us if you posted the error messages you are receiving. Quote Link to comment Share on other sites More sharing options...
hobden81 Posted May 21, 2009 Author Report Share Posted May 21, 2009 When I try filling out and sending the form on my local host I click send and the page just reloads but with the form boxies emptied. When I try it actually online, I get the error "error 500 - There is a problem with the resource you are looking for, and it cannot be displayed." I'm confused because I'm thinking that it might not just be a case of a problem with the script, the script might be fine, but just not for the server I'm using, if that makes sense? As they've mentioned the ini_set() function and fifth parameter of the mail() function which have not been in any sample script pages I've learned from. Is this information any help to pointing to what the problem might be? Quote Link to comment Share on other sites More sharing options...
hobden81 Posted May 27, 2009 Author Report Share Posted May 27, 2009 Any ideas anybody? Quote Link to comment Share on other sites More sharing options...
dms Posted May 27, 2009 Report Share Posted May 27, 2009 Maybe you should post the code from the form also. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.