0

I have been trying to get a website form submission to send an email. I have tested that mail works so I'm out of ideas on what I'm doing wrong. Please help.

I have been sent to other PHP submission code on stackoverflow and it still does not work.

PHP Code:

<?php   
$name = $_POST['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$input_342 = $_POST['input_342'];
$input_2152 = $_POST['input_2152'];

$from = 'From: *****.com';
$to = '*****@gmail.com'; // Email submissions are sent to this email
$subject = 'Customer Submission';

$body = "From: $name\n E-Mail: $email\n Message:\n $message";

if ($_POST['submit']) {
    if (mail ($to, $subject, $body, $from)) { 
        echo '<p>Your message has been sent!</p>';
        } else { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    }
}

HTML Form:

<form action="/includes/support_form.php" form id="support_form" method="POST">
    <div class="form-group">
        <label>Name</label>
        <input id="name" class="form-control" type="text" name="name" required/>
    </div>
    <div class="form-group">
        <label>Email</label>
        <input id="email" class="form-control" type="email" name="email" required/>
    </div>
    <div class="form-group">
        <label>Company Name</label>
        <input id="company" class="form-control" type="text" name="company" required/>
    </div>
    <div class="form-group">
        <label>Phone Number</label>
        <input id="phone" class="form-control" type="text" name="phone" required/>
    </div>
    <div class="form-group">
        <label>About Your Business</label><textarea id="message" class="form-control" rows="4" cols="50" name="message" type="text" required></textarea>
    </div>
    <div class="form-group">
        <label>Please Contact me by</label>
    </div>
    <div class="radio">
        <label><input type="radio" name="radioSetOne" value="option1" id="input_342"/>Email</label>
    </div>
    <div class="radio">
        <label><input type="radio" name="radioSetOne" value="option2" id="input_2152"/>Phone</label>
    </div>
    <button class="bloc-button btn btn-lg btn-block btn-sea-green" name="submit" type="submit">
        Submit
    </button>
</form>
luchaninov
  • 6,792
  • 6
  • 60
  • 75
Troy Wilson
  • 79
  • 2
  • 10
  • Please do not continue to repost the same question over and over. – Jay Blanchard May 11 '16 at 20:46
  • Sorry Jay, just trying to get some help on getting a solution that works. Please let me know if you have any suggestions on how to solve this. – Troy Wilson May 11 '16 at 20:50
  • Do yourself a favor, simply place a `print_r($_POST)` or `var_dump($_POST)` in the PHP page which receives the form submission. Fill out your form, submit and look closely at the data printed to the screen. Familiarize yourself with how form data is posted to scripts, including what gets passed and what doesn't. – Jay Blanchard May 11 '16 at 20:54

1 Answers1

0

You need add name="..." on all input (and button) You check whether there is a "submit". You need name="submit" in button.

And you can check that submits the form by using a network monitoring (firebug, google console)

id and type does not send in php

and you need write correct type... "text" or etc....

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Maxim Tkach
  • 1,607
  • 12
  • 23
  • I got the name="..." edited including for the button. I don't have any of the tools like firebug or google console setup. I just check to see if an email came through. No dice yet. – Troy Wilson May 11 '16 at 20:54
  • Script is response: '

    Your message has been sent!

    ' or '

    Something went wrong, go back and try again!

    ' or nothing?
    – Maxim Tkach May 11 '16 at 20:58
  • Ah, I found a 502 bad gateway error. – Troy Wilson May 11 '16 at 21:07
  • Sorry it seems that our mail server is not responding, Sorry for the inconvenience! - This is what I'm getting with the 502 bad gateway error. – Troy Wilson May 11 '16 at 21:17
  • Then it should be understood that the breaks. 1. Turn on the withdrawal of all errors. 2. displays the $ _POST 3. temporarily comment out mail If nothing is changed - see the logs of your server. – Maxim Tkach May 11 '16 at 21:18
  • Not scary. Clear. :) – Maxim Tkach May 11 '16 at 21:21