Jump to content

Part of url and more?


godsent

Recommended Posts

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"

Link to comment
https://forums.phpfreaks.com/topic/137106-part-of-url-and-more/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.