Travist6983 Posted April 13, 2013 Share Posted April 13, 2013 (edited) I am pulling my hair out here i want to send the page that the contact form was sent from. I have looked at a 1000 articles about how to do this (Not very good in PHP) But it isnt working for me. Here is the code for my form page <header> <img src="images/header.png"/> </header> <div id="page-wrap"> <div id="contact-area"> <form method="post" action="contactengine.php"> <label for="Name">Name:</label> <input type="text" name="Name" id="Name" /> <label for="City">Market:</label> <input type="text" name="Market" id="Market" /> <label for="Email">Email:</label> <input type="text" name="Email" id="Email" /> <input type="hidden" value="<?php echo $_SERVER['HTTP_REFERER'] ?>" name="Page" /> <input type="submit" name="submit" value="Submit" class="submit-button" /> </form> <div style="clear: both;"></div> </div> </div> And here is the file that i am posting too... <?php $EmailFrom = "sample@gmail.com"; $EmailTo = "sample@gmail.com"; $Subject = "Contact Form"; $Name = Trim(stripslashes($_POST['Name'])); $Market = Trim(stripslashes($_POST['Market'])); $Email = Trim(stripslashes($_POST['Email'])); $Page = $_POST['Page']; // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Market: "; $Body .= $Market; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Page: "; $Body .= $Page; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to landing page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=success.htm\">"; //Edit here for Landing Page } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> Everything is being populated on the email that is being sent except $Page which is the hidden field on the form. Am i missing a ";" somewhere that is breaking it? I am lost any help would be appreciated! Thanks in advance! Edited April 13, 2013 by Travist6983 Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 13, 2013 Share Posted April 13, 2013 (edited) Try, // change $Page = $_POST['Page']; to $Page = !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; Edited April 13, 2013 by jazzman1 Quote Link to comment Share on other sites More sharing options...
davidannis Posted April 13, 2013 Share Posted April 13, 2013 If you view source of the form page what does the hidden field look like? If the hidden field is empty are you following a link from a non-https page to get to your form. The referer is empty if you type the address into the bar directly, use a bookmark, and is stripped by some security software. I tested the form as posted and it looks like it is working. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted April 13, 2013 Share Posted April 13, 2013 I don't see any reason to set a $_SERVER['HTTP_REFERER'] into the html form. As @davidannis said if the form has been submitted the referer is gonna be set to the email message if not it is gonna be set to null . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.