-1

I am not sure what the issue, but when submitting the form it wont send email. Below is the code:

if (isset ($_POST['business_name']) && isset ($_POST['business_address']) && isset ($_POST['business_city']) && isset ($_POST['business_email'])) {

$business_name = $_POST['business_name'];
$business_address = $_POST['business_address'];
$business_city = $_POST['business_city'];
$business_email = $_POST['business_email'];

if (!empty($business_name) && !empty($business_address) &&!empty($business_city) && !empty($business_email))  {

$to = 'myemail@gmail.com'; 
$subject = 'New Submission From mywebsite.com';
$body = $business_name. "\n" . $business_address. "\n" . $business_city .          "\n" . $business_email;
$headers = "From:" . $business_email;

    if (@mail ($to, $subject, $body, $headers)) 

            }

        }


    ///i think everything is there but could be wrong im a beginner         

<form action="emailtest.php" method="POST">
<input id="busines_name" type="text" placeholder="Business Name" required>   <br />
<input id="business_address" type="text" placeholder="Business Address"   required><br />
<input id="business_city" type="text" placeholder="Business City & State" required><br />
<input id="business_email" type="email" placeholder="Your Email Address" required><br />
<input type="submit"value="SUBMIT">
</form>
arch
  • 1,363
  • 2
  • 14
  • 30
user2012105
  • 55
  • 1
  • 6
  • your input values need the `name` option to be used in `$_POST` – RST Feb 06 '16 at 10:21
  • yes actually i had name first but it didnt work then i changed it to id and still nothing. ive checked my server with a test code and it works. do i need both name and id? – user2012105 Feb 06 '16 at 10:24

1 Answers1

2

Change your input like this for all the fields

<input id="busines_name" name="busines_name" type="text" placeholder="Business Name" required>   <br />

You need to use the name option to make it work

RST
  • 3,899
  • 2
  • 20
  • 33