Where Did that Inquiry Come From? Contact Form Previous Page Detection in PHP

A white, rounded square logo with an abstract S-shaped design on a gradient blue and purple background.

It’s great to see where contact forms are submitted from. It allows you to track which pages are effective in landing inquiries. In addition to the standard info (name, email, phone), you can also detect what pages they submitted the form from.

Here is one of our standard inquiry forms with data excluded:


Name: ***********
Firm Name: ***********
Email: ***********
Phone: ***********
Question: Looking to update our current website: www. ***********.com. Could you provide us with a quote? Would like to add some photos and possibly video to our site and email contact option.

Referral Page: https://www.paperstreet.com/web-design/


In that case, the person visited our web design page and submitted their info. How did we know that?”  We used the HTTP_REFERER command.

Command to Use


The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

Code to Use

<?php echo “Referral Page: ” . $_SERVER[‘HTTP_REFERER’]; ?>

Share This

Join the Sales and Marketing News, receive our last insights, tips and best practices.

Our 7 Guarantees

Keeping 2,000+ Clients Happy Since 2001.

You Will Love Your Design We design to please you and your clients
Same-Day Support 24-hour turnaround edits during business hours
Free Education We provide knowledge to help you expand
No Hidden Charges We quote flat-rate projects
Own Your Site No strings attached
We Create Results SEO, PPC, content + design = clients
We Make Life Easier One agency for web, branding and marketing