I have php file with html coding inside. I'm using include statement to import the same form into many different pages, however I need to know which page the form was submitted from. Files themselves are .php, however the most of coding is in html. How can I add the current URL of the website the form was submitted from? I use post method.
<form action="post.php" method="post">
<input type="hidden" name="url" value="(Current URL here)" />
<input type="text" id="email" name="email">
</form>
and php part:
<?php
$addressto = "mail@mail.com";
$subject = "Message";
$content = "Email: ".$_POST['email']."\n"
."URL: ".$_POST['url']."\n";
$email = $_POST['email'];
if (mail($addressto, $subject, $content, 'From: <' . $email . '>')) {
header("Location: message-sent.html");
}
?>
I believe I need some sort of code that gets URL. I found few similar questions here but none of them clearly explains how to do it. Thank you for your help.