• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Target top with redirect with php

I am using a php page to send users to after registration. Depending on the variables received it redirects them to certain pages. I am currently handling the registration payment from within an iframe because the payment is made outside of our site. I have very little control as to functionality from the payment page, I only have the option to set a redirect back to my site which I have added queries for variables in the url. This is all done in my iframe so that it keeps my users on our site.
I have it all working except it doesn't redirect out of the iframe to the top. It loads our site again within the iframe.

How can I target the top with a redirect with php? If this can only be done with a client side script how can I do it with JavaScript?

Here is my current code of the landing page they are redirected to from the payement page. From this page I want to write a script that according to the query it will redirect them but target it to the top to do this.

Thanks in advance!

<?php
$reg_mdya = $_GET['reg_id']; 
$verifyConf = $_GET['st'];
 
if ($reg_mdya == 'm2d2y1a3l4a4') {
header("Location: http://www.starteconome.com?page_id=2213");
 
} else {
header("Location: http://www.starteconome.com?page_id=95");
}
?>

Open in new window

0
Shaye Larsen
Asked:
Shaye Larsen
  • 3
1 Solution
 
RobinSoftware EngineerCommented:
You have to do it at the client side in javascript.

Have a look at http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23731078.html
0
 
Shaye LarsenAuthor Commented:
Thank you for your help.

I still can't get it to go. I have tested for a bit and this is the best I have come up with. The following php works. It includes the correct javascript but it doesn't even perform the redirect. When I view the source it is just shows the javascript sitting there on the page without directing.

Take a look:
registered.php:
 
<?php
$reg_mdya = $_GET['reg_id']; 
$verifyConf = $_GET['st'];
 
if ($reg_mdya == 'm2d2y1a3l4a4' && $verifyConf == 'Completed') {
include("red_reg_true.php");
 
} else {
include("red_reg_false.php");
}
?>
 
red_reg_true.php:
 
<script type="text/javascript">
window.parent.location.href='http://www.starteconome.com/?page_id=2213';
</script>

Open in new window

0
 
Shaye LarsenAuthor Commented:
I got it to work with window.top.location.href='myUrl';

Thanks!
0
 
Shaye LarsenAuthor Commented:
Thank you! See post ID:23724827 for full solution.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now