Jeffro Posted May 1, 2012 Share Posted May 1, 2012 I had an iframe working for the last few months on a site at hostgator. Yesterday, it quit working (403 permissions error). After a long bout of trouble-shooting, I found out that it has something to do with mod_security that they have suddenly enabled (have no idea as I'm not a Linux guy). They told me they fixed the problem on my domain by whitelisting it as an exception, but strangely, even though the permissions error went away, the actual src= box of the iframe, which was the url variable I was passing in the url, no longer loads. So.. I'm trying to break this down into the simplest form to figure it out. I just understand php basics so needing some verification that I'm doing this right/wrong. Here's my code.. page1.php <? $testurl = "http://google.com"; ?> <a href="http://mysite.blah/page2.php?url=<? echo $testurl; ?>">page2.php</a> page2.php if (isset($_GET['testurl'])) echo $testurl; else echo "sorry dude"; I am only able to print "sorry dude". Am I doing something wrong or shouldn't this send the url? Thanks for the help! Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 1, 2012 Share Posted May 1, 2012 print_r($_GET); on page two and you will see the problem. Quote Link to comment Share on other sites More sharing options...
Jeffro Posted May 1, 2012 Author Share Posted May 1, 2012 print_r($_GET); on page two and you will see the problem. That was some fast help! Okay.. this definitely helps.. but not quite sure what it means. I get this: Array ( [url] => http://google.com ) Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 1, 2012 Share Posted May 1, 2012 Then the code you provided in your OP is not your actual code. Neither of those snippets contains listing. You also called it page2 but your code says test2. Quote Link to comment Share on other sites More sharing options...
Jeffro Posted May 1, 2012 Author Share Posted May 1, 2012 Then the code you provided in your OP is not your actual code. Neither of those snippets contains listing. You also called it page2 but your code says test2. (Sorry.. just updated. I was testing with 2 different pages.. basically both doing the same thing) Quote Link to comment Share on other sites More sharing options...
marcus Posted May 1, 2012 Share Posted May 1, 2012 To get the ?url=<blah> from your code you use the superglobal $_GET and index it with url. So on the second page you just have $url = $_GET['url']; if(isset($url)){ echo $url; } else { echo "sorry dude"; } Quote Link to comment Share on other sites More sharing options...
Jeffro Posted May 1, 2012 Author Share Posted May 1, 2012 Didn't realize I didn't put that here.. but yes, I had it in there. Okay.. to avoid confusion, here is a copy/paste of my test1.php and test2.php (only the domain name has been changed): test1.php: <?php $testurl = "mytest"; echo $testurl; echo '<br>'; ?> <a href="http://domain.com/test2.php?testvar=<? echo $testurl; ?>">test2.php</a> test2.php: <? $testurl = $_GET['testurl']; ?> <html> <head> </head> <body> <? if (isset($_GET['testurl'])) { echo $testurl; echo '<br>'; } else { echo "sorry dude"; echo '<br>'; } print_r($_GET); ?> </body> </html> And here is the output of test2.php: sorry dude Array ( [testvar] => mytest ) Quote Link to comment Share on other sites More sharing options...
ajrockr Posted May 1, 2012 Share Posted May 1, 2012 <a href="http://domain.com/test2.php?testvar=<? echo $testurl; ?>">test2.php</a>[/code] sorry dude Array ( [testvar] => mytest ) test2.php: $testurl = $_GET['testurl']; Testurl does not equal testvar you are passing testvar as your $_GET but not looking for that var in your test2 page, instead you are looking for testurl which doesnt exist because your are using testvar. either change testvar in your url link to testurl or vice versa and you'll work <? if (isset($testurl)) { // because you have already made $testurl you dont need the $_GET anymore echo $testurl; echo '<br>'; } else { echo "sorry dude"; echo '<br>'; } print_r($_GET); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
marcus Posted May 1, 2012 Share Posted May 1, 2012 Is it not obvious? You're passing testvar, but looking for testurl. Quote Link to comment Share on other sites More sharing options...
Jeffro Posted May 1, 2012 Author Share Posted May 1, 2012 thanks, ajrocker.. I think that did it! I guess that should have been obvious, but I honestly just rarely do php.. and only the minimal change here or there when I need it a few times a year. I thought the name in the url (testvar=) could be anything and was just used as an identifier while the get had to match the actual $variable from the prior page. Thanks much for the help.. and the print_r command! (jesirose). Handy! 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.