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>