Jump to content

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.