Skip to main content
Participating Frequently
July 25, 2009
Question

Really strugling with sendmail.php please help

  • July 25, 2009
  • 2 replies
  • 1389 views

Hi All,

Please could anyone tell me why the following is not working ?

Ok firstly this is the text that makes up the form on the webpage:

<form action="sendmail.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
         <table class="form">
          <tr>
           <td style="height:26px"><input name="Name" type="text" value="Name"></td>
          </tr>
          <tr>
           <td style="height:26px"><input name="E-mail" type="text" value="E-mail"></td>
          </tr>
          <tr>
           <td style="height:26px"><input name="Phone" type="text" value="Phone"></td>
          </tr>
          <tr>
           <td style="height:140px"><textarea name="Message" cols="0" rows="0">Message</textarea><br>
            <br style="line-height:9px">
            <div style="text-align:right">
             <span><a href="
head.office@mysite.co.uk" onClick="document.getElementById('form1').reset()">clear</a></span><img src="images/spacer.gif" alt="" width="10" height="1"><span><a href="head.office@mysite.co.uk" onClick="document.getElementById('form1').submit('form1')">send</a> </span></div>
           </td>
          </tr>
         </table>
        </form>

Ok secondly this is the text that makes up the sendmail.php file:

<?php
$to =
'head.office@mysite.co.uk';
$subject = 'Feedback form results';

// prepare the message body
$message = 'Name: ' . $_POST['Name'] . "\n";
$message .= 'E-mail: ' . $_POST['E-mail'] . "\n";
$message .= 'Phone: ' . $_POST['Phone'] . "\n";
$message .= 'Message: ' . $_POST['Message'];

// send the email
mail($to, $subject, $message, null,
'-fhead.office@mysite.co.uk');
header('Location:
http://www.mysite.co.uk/thankyou.html');
?>

I really have no idea why this is not working, when you fill out the form on the website and click the send button it just comes up with an error message, please can anyone help me ? My head is most confused now !!

Thankyou.

This topic has been closed for replies.

2 replies

David_Powers
Inspiring
July 26, 2009

Thread moved to Dreamweaver Application Development forum, which deals with server-side issues.

andy7719Author
Participating Frequently
July 26, 2009

Thankyou David i never realised i had posted in the wrong area ha ha

I have now got the thankyou page working and the form is now sent to the email address when the send button is pressed, the only problem i am now having is that whatever information is input into the form is not showing on the final email.

Hmmmmm im confused !!

Community Expert
July 25, 2009

You say you get an error message. What does it say?

andy7719Author
Participating Frequently
July 25, 2009

the actual error is a 404, i have contacted the web host and they told me that ment the sendmail.php file was in the wrong place, so i corrected that problem and i still get the error, now they say there is a problem with the head.office@mysite.co.uk bit, they said its trying to find a page in the public_html folder which does not exist ? for starters its an email address so i have no idea what they are going on about ?

any help really would be great !!

Community Expert
July 25, 2009

A 404 error is a page not found error.  So depending on where this is happening it can be for one of two reasons based on your script:

First, based on your form, the form html document needs to be in the same directory as the sendmail.php file.  If it is not that is one possible cause.

The second is with your thankyou page.  Does that page exist where you are redirecting to?  If that does not that is the only other possibility of where the 404 error could be coming from.

Check those two options to make sure everything is in place.  If you are not getting the form in your email I would lean towards the first solution.

If you are still experiencing problems after the 404 problem is solved post back.