Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Really strugling with sendmail.php please help

New Here ,
Jul 25, 2009 Jul 25, 2009

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.

TOPICS
Server side applications
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2009 Jul 25, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2009 Jul 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 !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 25, 2009 Jul 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2009 Jul 25, 2009

i will take a look, thankyou for your help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2009 Jul 26, 2009
LATEST

andy7719 wrote:

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 ?

Yes, the problem is the way you have set up the reset and submit parts of the form. Your code looks like this:

<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>

You can't use an email address with href. To create an email link you use mailto instead of href. However, since you're using a PHP script, you don't want a link at all. You should be using reset and submit buttons instead.

<input type="reset" name="clear" id="clear" value="Clear" />
<input type="submit" name="send" id="send" value="Send" />

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2009 Jul 26, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2009 Jul 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 !!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines