I am trying to send data from HTML to PHP. Here is my html code:
<div class="content">
<form action="email-script.php" method="post">
<div class="contact-form mar-top30">
<label> <span>Full name</span>
<input type="text" class="input_text" name="name" id="name"/>
</label>
<label> <span>Email</span>
<input type="text" class="input_text" name="email" id="email"/>
</label>
<label> <span>Subject</span>
<input type="text" class="input_text" name="subject" id="subject"/>
</label>
<label> <span>Message</span>
<textarea class="message" name="feedback" id="feedback"></textarea>
</label>
<label>
<input type="submit" class="button" value="Send" />
</label>
</div>
</form>
</div>
And here is my php code:
<!DOCTYPE html>
<html>
<?php
$email=$_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["name"] . "Sent this email" . "\r\n" . $_POST["feedback"] . "Sent from this email address:" . $_POST["email"];
mail("[email protected]", $subject, $message);
//header("Location: index.html");
?>
Error, please contact Jack at ([email protected]) <br>
email: <?php $email ?> <br>
subject: <?php $subject ?> <br>
message: <?php $message ?> <br>
</html>
I was thinking the best way to do this was through a POST method. How do I go about sending all of the data from the html form to the php email script via the click of the submit button. Posted below are screenshots of the issue.
Before submit:

After submit:

just add echo before your output variables
email: <?php echo $email ?> <br>
subject: <?php echo $subject ?> <br>
message: <?php echo $message ?> <br>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With