easyedy Posted December 28, 2007 Share Posted December 28, 2007 I ran into a prob here with my includes and forms... I'm trying to call a form action for the current page but since the file is an include and froma different host it's returning that host info. Here is what the page looks like: Page is http://www.site.com/page1.php?ord=354 HTML include('http://domain.com/file.php') whcih is <form action="'. $_SERVER['PHP_SELF'].'" method="get"> <b class="textVerdana">Filter By</b> <select name="sortby" onchange="this.form.submit();"> <option value="id">Id</option> <option value="aame">Name</option> <option value="qty">Quantity</option> </select> </form> HTML But the $_SERVER['PHP_SELF'] is calling http://domain.com/file.php' when I need it to call http://www.site.com/page1.php?ord=354. Can I do this with PHP or do I need js? Quote Link to comment https://forums.phpfreaks.com/topic/83522-calling-current-url-in-address-bar-from-an-include/ Share on other sites More sharing options...
p2grace Posted December 28, 2007 Share Posted December 28, 2007 Try using this instead $_SERVER['REQUEST_URI'] Quote Link to comment https://forums.phpfreaks.com/topic/83522-calling-current-url-in-address-bar-from-an-include/#findComment-424944 Share on other sites More sharing options...
monkeytooth Posted December 28, 2007 Share Posted December 28, 2007 If im understanding you right its possible with PHP or should be.. But Im really sleepy right now so the solution evades me, I deffinately want to say that I think it involves your $_SERVER['PHP_SELF'].. cause the php_self part defines your page your site, not the refering site or link from. But the problem is these urls in mention are the dynamic or static? if they are static why not hard code it.. or are you looking for a specific variable? You need to go more in depth as to what your doing with your page vs. where the other URL is coming from and what its for and so on.. give a live example even :-) Quote Link to comment https://forums.phpfreaks.com/topic/83522-calling-current-url-in-address-bar-from-an-include/#findComment-424947 Share on other sites More sharing options...
easyedy Posted December 30, 2007 Author Share Posted December 30, 2007 Hmmm... maybe this is a better explanation. URL - http://www.domain.com/mypage.php code is this This is my sort page<br><? php include('http://www.otherdomain.com/sort.php'); ?> The include URL - http://www.otherdomain.com/sort.php <? php echo '<form action="'. $_SERVER['REQUEST_URI'] .'" method="get"> <b class="textVerdana">Filter By</b> <select name="sortby" onchange="this.form.submit();"> <option value="id">ID</option> <option value="name">Name</option> <option value="qty">Quantity</option> </select> </form>'; ?> So since http://www.otherdomain.com/sort.php is different than http://www.domain.com/mypage.php the $_SERVER['REQUEST_URI'] is returning /sort.php which will cause the form not to work. Quote Link to comment https://forums.phpfreaks.com/topic/83522-calling-current-url-in-address-bar-from-an-include/#findComment-426101 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.