So I'm fairly new to wordpress and not well knowledgable on how things work, so please a detailed answer on what I should be doing would be great!
So basically I created a form that takes in input from user does some calculations and then when they press submit that input is sent to me in an email.
It works just fine on a site that isn't ran by wordpress but on my other site it just wont send, I know the php code is running but the mailing isn't, would really love some help. Just to add this code is placed in the page section I think they're referred to by Gotenberg.. could be wrong.
I was using <?php ?>
of course, but the php could wasn't running so I had to install a plugin and use this [insert_php] [/insert_php]
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<div class="col-md-12">
<!-- <small><i></i>Add alerts if form ok... success, else error.</i></small>
<div class="alert alert-success"><strong><span class="glyphicon glyphicon-send"></span> Success! Message sent. (If form ok!)</strong></div>
<div class="alert alert-danger"><span class="glyphicon glyphicon-alert"></span><strong> Error! Please check the inputs. (If form error!)</strong></div>
</div>-->
<form role="form" action="" method="post" id="fr1">
<div class="col-lg-6">
<!--<div class="well well-sm"><strong><i class="glyphicon glyphicon-ok form-control-feedback"></i> Required Field</strong></div>-->
<div class="form-group">
<label for="InputName">Your Initial SR</label>
<div class="input-group">
<input type="text" class="form-control" name="value1" id="value1" placeholder="Enter initial SR" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<label for="InputName">Your Desired SR</label>
<div class="input-group">
<input type="text" class="form-control" name="value2" id="value2" placeholder="Enter desired SR" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<label for="InputEmail">Your Email</label>
<div class="input-group">
<input type="email" class="form-control" id="InputEmail" name="InputEmail" placeholder="Enter Email" required >
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<label for="InputMessage">Message</label>
<div class="input-group">
<textarea name="InputMessage" id="InputMessage" class="form-control" rows="5" required></textarea>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span></div>
</div>
<div class="form-group">
<!--<label class="control-label col-sm-2" for="diff">Difference</label>-->
<input type="hidden" name="diff" id="diff" class="form-control" readonly />
</div>
<div class="form-group">
<label for="InputName">Total Price</label>
<div class="input-group">
<input type="number" name="price" id="price" class="form-control" readonly />
</div>
<input type="submit" name="submit" id="submit" value="Submit" class="btn btn-info pull-right">
</div></div>
</form>
</div>
</div>
</div>
[insert_php]
if(isset($_POST['submit'])){
$to = "myemail@hotmail.com"; // this is your Email address
$from = $_POST['InputEmail']; // this is the sender's Email address
$first_name = $_POST['value1'];
$last_name = $_POST['value2'];
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['InputEmail'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$message,$headers);
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
[/insert_php]