Jump to content

Cant understand where the problem/s lie.


hobden81

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...