shabzo Posted August 23, 2013 Share Posted August 23, 2013 I have the following in my index.php page <?php $url='http://www.external site.co.za';?> in the html side <a href="#B"><div name="B" href="'.$URL.'" class="fancybox"></a> The link does not open and says that it cant find the page . Is it becuase it is an external page. The whole idea is not to display the external sites name. the way it works correctly: but this shows the external file address <a href="#B"><div name="B" href="http://www.external site.co.za" class="fancybox"></a> Thank you Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/ Share on other sites More sharing options...
kicken Posted August 24, 2013 Share Posted August 24, 2013 div tags do not have an href attribute. Perhaps you mean <iframe> ? Using an iframe would show the site without it's URL being visible in the URL bar, but it would still be visible in the source of the page, so it's not really hidden. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446502 Share on other sites More sharing options...
shabzo Posted August 24, 2013 Author Share Posted August 24, 2013 this is in my index.php <?php $url="http://xternalsite.co.za";?> in the same page on my navigation the html side i have <script type="text/javascript"> $(document).ready(function() { $(".fancybox" ).fancybox({ 'width' : '45%', 'height' : 550, 'autoSize' : true, 'autoDimensions' : false, 'fitToView' : false, 'titlePosition' : 'inside', 'transitionIn' : 'none', 'scrolling' : 'auto', 'transitionOut' : 'none', 'href' : $(this).attr('href'), 'type' : 'iframe' }); }); </script> <script type="text/javascript"> document.getElementById("container").style.display = "none"; </script> <nav> <a href="#A"> <div id="container" name="A" href="'.$url.'" class="fancybox"> Click</div></a></li> </nav> the button om nav does not find the url specified Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446504 Share on other sites More sharing options...
shabzo Posted August 24, 2013 Author Share Posted August 24, 2013 and if i do it this way it works but the address is seen if the page source is seen. Banking</a></li><li><a href="#A"> <div id="container" name="A" href="http://xternalsite.co.za" class="fancybox"> RaceCards</div></a></li> Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446505 Share on other sites More sharing options...
Psycho Posted August 24, 2013 Share Posted August 24, 2013 Um, yeah. It's impossible to send a user to a page without them being able to see the address somewhere in the code. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446508 Share on other sites More sharing options...
shabzo Posted August 24, 2013 Author Share Posted August 24, 2013 ok . what if I do this the user then sees selections as the page that he selected and not the actual http://xternalsite.co.za" this is in my index.php <?php $url="http://xternalsite.co.za";?> and the html <nav> <a href="#Selections"> <div id="container" name="Selections" href="'.$url.'" class="fancybox"> Selections</div></a></li> </nav> Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446524 Share on other sites More sharing options...
shabzo Posted August 24, 2013 Author Share Posted August 24, 2013 What I am trying to do is keep user within my url. User opens external url in iframe and sees data which he cannot edit and then closes the iframe. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446525 Share on other sites More sharing options...
shabzo Posted August 24, 2013 Author Share Posted August 24, 2013 i manged to do this but it still not what i wanted. in my index.php i got the following <?php if (isset($_GET['run'])) $linkchoice=$_GET['run']; else $linkchoice=''; switch($linkchoice){ case 'first' : header("Location: http://www.the other site"); break; case 'second' : header("Location: /index.php") ; break; } ?> in html <p class="submit"> <a href="?run=first" class="fancybox" style="position: absolute; left:221px; top:129px"> <p><input type="submit" value="Selections"></p></a></p> this works fine unless user types in http://www.mysite.php?run=first it opens the other but site not in my iframe. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446545 Share on other sites More sharing options...
Irate Posted August 24, 2013 Share Posted August 24, 2013 You can set up spoof links that show a href attribute of something else and then use header("Location: /new_address.php"), but as user, I'd be highly displeased if a site would try to link me somewhere else than it specified... Example below. <!-- yoursite.php --> <a href="redirect.php">Click to redirect</a> <!-- end of yoursite.php --> <?php // redirect.php if(isser($_SERVER['HTTP_REFERER']) && preg_match(~yoursite\.php~i,$_SERVER['HTTP_REFERER'])){ header("Location: newsite.php"); } else { header("Location: othersite.php"); } // end of redirect.php ?> Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446589 Share on other sites More sharing options...
shabzo Posted August 25, 2013 Author Share Posted August 25, 2013 ok tks . is this how I should do it. please check if(isset) if correct cos this opens nothing in my redirect.php <?php // redirect.php if(isset($_SERVER['HTTP_REFERER']) && preg_match(http//www.mysite.co.za\.php~i,$_SERVER['HTTP_REFERER'])){ header("Location: http://www.site1.co.za"); } else { header("Location: http//www.mysite.co.za"); } // end of redirect.php ?> thanks Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446642 Share on other sites More sharing options...
Irate Posted August 25, 2013 Share Posted August 25, 2013 Your Regular Expression is a bit off... preg_ functions take for each Regular Expression a string which starts with one sign and ends with the same sign, optionally followed by g, i or m (or a combination of those). I noticed that I myself didn't put them in strings, but since I was on my phone, I did not feel like editing it. Anyway. preg_match("~yoursite.co.za/filename.php~i",$_SERVER['HTTP_REFERER']) should do the trick. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446643 Share on other sites More sharing options...
shabzo Posted August 25, 2013 Author Share Posted August 25, 2013 this is waht i have and i get a blank fancybox <?php // site.php if(isset($_SERVER['HTTP_REFERER']) && preg_match("~http://www.horsespeedracing.co.za/index.php~i",$_SERVER['HTTP_REFERER'])){ header("Location: http://www.gallop.co.za"); } else { header("Location: http//www.horsespeedracing.co.za"); } // end of redirect.php ?> in my testing.php i have <p class="submit"> <a href="site.php" class="fancybox" style="position: absolute; left:221px; top:129px"> <p><input type="submit" value="VIDOE"></p></a></p> this is my example i have to test that works. but the user can still go direct if they type new_page-3.php?run=first Try http:www//horsespeedracing.co.za/php_login_v2.3/phplogin_v2.3/new_page_3.php Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446647 Share on other sites More sharing options...
shabzo Posted August 25, 2013 Author Share Posted August 25, 2013 Thank you It works . Thank you so much for your help. is there anyway i can block the url showing in the browser in the far left corner? Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446655 Share on other sites More sharing options...
Irate Posted August 25, 2013 Share Posted August 25, 2013 That's the one thing you cannot hide unless you'd create your own browser and distribute it to every single internet user. Sadly, you are not a multi-billion company like Google to afford that (I guess, I highly doubt it), so the answer to that is no. There is no way to prevent the user from getting the link from SOMEWHERE out of your code, be it now the href attribute or some JavaScript-implemented redirect, the user would be able to figure it out. You could, if you are very eager for the user not to know where to redirect, try JavaScript code obsfuscation, but that's a pretty shameful thing to do unless you are actually trying to hide crucial data (and even then, you'd be doing it wrong - storing data with JavaScript is generally a bad idea and easily discovered). Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446712 Share on other sites More sharing options...
Psycho Posted August 26, 2013 Share Posted August 26, 2013 Well, there is a way to display the 'content' of that external page without the user actually loading the page. But, it involves screenscraping which is frowned upon. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446761 Share on other sites More sharing options...
shabzo Posted August 26, 2013 Author Share Posted August 26, 2013 Thank you for all the help. I definitely don't know how to do scrapping and do not want to exploit my website with illegal stuff. Quote Link to comment https://forums.phpfreaks.com/topic/281503-how-to-hide-href-with-php/#findComment-1446806 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.