mail() error someone please help!

[php]

<?php $name = $POST_['name']; $email = $POST_['email']; $subject = $POST_['subject']; $body = $POST_['query']; mail("[email protected]", "$subject", "$body", "From: '$name' : '$email'"); ?>[/php]

MOD EDIT: Corrected Incorrect Usage of PHP bb code tags

Above is my php code to send an email with what a user types in the form. I am currently getting blank emails sent to my address and was wondering if someone can tell me where I went wrong.

This is probably something simple as I am a beginner and have had very little php experience.

All help is greatly appreciated.

echo/print out the indiviual pieces and make sure the variable is actually moving in. Oh and it’s $POST not $POST

I have tried this and the variables are not working. I have changed it to $_POST so it can’t be that.

Any ideas?

If indeed your code is like

[php]

<?php $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $body = $_POST['query']; mail("[email protected]", "$subject", "$body", "From: '$name' : '$email'"); ?>

[/php]

Then I would have to ask, how are you sending the info? What is the code for the submitting page? Is it using a POST for it’s METHOD? Is the ACTION pointing to the page that has the above code? Are there any errors being displayed? Is the error reporting turned on in the PHP.INI?

If the variables are not working (as you suggested), then I would look at how you are submitting them to thies page.

Can we see the new chunk of code?

[code]

Get an 0845 Local Rate Number To

Simple support is available by the below form:-

             Name: 

Email Address: 

          Subject: 

           Query: 

 

For add-on support packages click here.

[/code]

Above is the code I am using to submit the data. It can be previewed at http://www.07005.net/test/contact%20body.htm[/url]

I am not 100 percent sure, but I do believe you need to have all of your FORM elementes enclosed in the tags.

<form method="POST" action="sent.php">
   Name:&nbsp; <input type="text" name="name" size="20"></p>
  <p>Email Address:&nbsp; <input type="text" name="email" size="20"></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Subject:&nbsp;
  <input type="text" name="subject" size="20"></p>
  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Query:&nbsp;
  <textarea rows="8" name="query" cols="32"></textarea></p>
  <p>&nbsp;</p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> 
</form>

It works :D

Thanks everyone for your help

Sponsor our Newsletter | Privacy Policy | Terms of Service