Solved

Redirect to first page form

Posted on 2014-03-12
8
541 Views
Last Modified: 2014-03-12
Hi there.  My WordPress site uses Gravity forms and on my site I have 2 forms.  I am passing a few parameters in the url from the first form to the second form such as email.

Now, I do not want the user to access this second page directly but only if they come via the first form page.  Is there something in functions.php or .htaccess (using http referer) or a conditional on that second form that will automatically redirect the user to that first form?

Thanks!
0
Comment
Question by:COwebmaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39924705
Use $_SERVER['HTTP_REFERER'];
Will give the previous page url
0
 

Author Comment

by:COwebmaster
ID: 39924714
Okay, so what would I create and which file or page?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39924735
On your second page

if($_SERVER['HTTP_REFERER']!="http://www.yoursite.com/yourpage.php"){
// what should happen if they haven't come from the previous page, redirect etc
}

Open in new window


Note everything is passed in the REFERER string including any querystring params.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:COwebmaster
ID: 39924802
okay, on my wordpress site, I installed a php plugin so I can embed php code on the page.

I've set your code but need to place the redirect line of code in there.  What would that be?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39924810
header('Location: '.$newURL);

if($_SERVER['HTTP_REFERER']!="http://www.yoursite.com/yourpage.php"){
     header('Location: newurl.php');
}
0
 

Author Comment

by:COwebmaster
ID: 39924827
Okay, I tried but the page is not redirecting. I have:

<?php
if($_SERVER['HTTP_REFERER']!="http://www.domain.com/page-1/"){
header('Location: http://www.domain.com/page-1/');
}
?>
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39924844
Should be checking it is set first...

if(!isset($_SERVER['HTTP_REFERER'])||$_SERVER['HTTP_REFERER']!="http://localhost/tt.php"){
     header('Location: http://www.domain.com/page-1/');
}

Open in new window

0
 

Author Closing Comment

by:COwebmaster
ID: 39924884
That worked, thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question