godsent Posted December 15, 2008 Share Posted December 15, 2008 Well to get some part of URL im using this code <?php if(isset($_GET['uid']) && file_exists('page/'.$_GET['uid'].'.php')){ include"page/".$_GET['uid'].".php"; } else if (!@ $_GET['uid']) { include"page/main.php"; } else { include"page/404.php"; } ?> so if URL is index.php?uid=edit_post, this will include page/edit_post.php file. What im trying to do is: 123 = post id. For my way of editing post i must include somewhere post id, for example index.php?uid=edit_post,123 But then that file cannot be included because web search for file edit_post,123.php. Im searching for the way to open edit_post.php file and getting "123". its possible to use $path = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $file = basename($path); $file = basename($path, ".php"); $user = strstr($file, ','); $pre_replace = str_replace(",", "", "$user"); but i don't really understand how to include edit_post.php without "123" Quote Link to comment https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/ Share on other sites More sharing options...
B34ST Posted December 15, 2008 Share Posted December 15, 2008 You can use something like the following url: index.php?mode=edit_post&post=123 then retrieve the data: $mode = $_GET['mode']; $post = $_GET['post']; Quote Link to comment https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/#findComment-716147 Share on other sites More sharing options...
godsent Posted December 15, 2008 Author Share Posted December 15, 2008 You can use something like the following url: index.php?mode=edit_post&post=123 then retrieve the data: $mode = $_GET['mode']; $post = $_GET['post']; thanks man! i didnt knew that "&" didnt ruin whole url, people are really helpful in this community Quote Link to comment https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/#findComment-716151 Share on other sites More sharing options...
B34ST Posted December 15, 2008 Share Posted December 15, 2008 In that case you might not be aware that you can have as many as you like (at least i am not a aware of any limitations) example: index.php?mode=edit_post&uid=4&post=123 Yes this is a great community with a lot of knowlegeable members. Quote Link to comment https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/#findComment-716164 Share on other sites More sharing options...
Maq Posted December 15, 2008 Share Posted December 15, 2008 If you're unsure of the amount or what name the variables are, you can use a foreach loop to retrieve all of them: foreach($_GET as $key => $value) { echo "key: " . $key . " value: " . $value . " "; } Quote Link to comment https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/#findComment-716208 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.