I am new to PHP but have a site that I need to go live and I cant get the form to work.
Basically what it does is send JUST whats in the "message" field. All other fields are blank for some reason. Also, if possible, I would like help getting it to put a confirmation of "sent mail" without redirecting to a new page, but rather just a pop up message in the form itself.
So here is the code.
<form method="post" action="index.php">
<div class="form-group">
<input class="form-control" name="name" placeholder="Name" type="text">
</div>
<div class="form-group">
<input class="form-control" name="email" placeholder="Email" type="text">
</div>
<div class="form-group">
<input class="form-control" name="text" placeholder="Which class are you interested in?" type="text">
</div>
<div class="form-group">
<input class="form-control" name="phone" placeholder="What is the best number to you reach you?" type="text">
</div>
<div class="form-group">
<textarea class="form-control" name="message" placeholder="Message" rows="3"></textarea>
</div>
<input class="btn btn-block" type="submit" name="submit" value="Submit">
</form>
and here is the PHP
<?php
$Name = $_POST['name'];
$Email = $_POST['email'];
$Class = $_POST['class'];
$Phone = $_POST['phone'];
$Message = $_POST['message'];
$from = 'From: **** Site';
$to = '**********@gmail.com';
$subject = 'Message from **** Site';
$body = "From: $Name
E-Mail: $Email
Class: $Class
Phone: $Phone
Message:
$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>';
}
}
?>
Any help here would be greatly appreciated.