What should be the PHP code so that I can receive the email address of the person who submits his email address

I have already linked my newsletter subscription box given in contact.html with newsletter.php
But when I am trying to send the email address in the subscription box to my mailbox, I am not receiving the email address given in the box rather I am receiving a blank mail.enter image description here
contact.html Code
<div class="form-element">
<form action="newsletter.php" method="post">
<input name="email" type="email" placeholder="Email" required><span><a href="newsletter.php"><i type="submit" class="fas fa-chevron-right"></i></a></span>
</form>
</div>
newsletter.php Code
<?php
$visitor_email = $_POST['email'];
$email_from = '[email protected]';
$email_subject = "Newsletter Subscribtion";
$email_body = "Subscriber Email: $visitor_email.\n";
$to = "[email protected]";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: contact.html");
?>
Answer
Solution:
Form Code:-
<div class="form-element">
<form action="newsletter.php" method="post">
<input name="email" type="email" placeholder="Email" required>
<i type="submit" class="fas fa-chevron-right"><input type="submit" name="submit" value="Email Now"></i>
</form>
</div>
Mail Code:-
<?php
$visitor_email = $_POST['email'];
$email_from = '[email protected]';
$email_subject = "Newsletter Subscribtion";
$email_body = "Subscriber Email: $visitor_email.\n";
$to = "[email protected]";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: contact.html");
?>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the browser (or proxy) sent a request that this server could not understand.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.