I have a static .html site and I want to implement a very simple subscription form. It will be implemented together with an external javascript lightbox popup hosted by a third-party developer which is why my subscription form will only be a simple one.
I don't have much knowledge in HTML/PHP programming. So upon searching online, I found a template code that looks like below:
In my .html page:
<form action="mail.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<input type="submit" value="Send">
</form>
And in my mail.php:
<?php $name = $_POST['name'];
$email = $_POST['email'];
$formcontent="From: $name";
$recipient = "[email protected]";
$subject = "Subscription Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
So far, the above is working. BUT I also want to automatically include the referring page on the form, that is the page within my website where they submitted the info in the subscription form. Because the subscription form will be on many different pages of the site, obtaining this information is valuable so I know what page is generating the most subscription.
I understand that there's a feature called "HTTP_REFERER"
But I don't know how to code and where to put that code so that the referral link will also be submitted on the email.
Can someone help with what I need to do or add using the sample codes I used above?
Note that I understand security issues but this is only a basic sample form (security modifications will be added later on) and I just need to know how HTTP_REFERER can be added.
Many thanks!
[email protected]\r\nTo: [email protected]
they would be able to send a spam copy of the message to Bob. It might be possible to craft malware attachments or any number of other malicious attacks.$_SERVER['HTTP_REFERER']
could be included in the message, either as headers or in the body. Like other submitted values they should checked to make sure they are in the expected format (sanitized) before they are used.