Jump to content

Recommended Posts

Greetings,

 

Again having issues.

 

I have a site where one page is shown (index.php) and it randomizes the content, but keeps the URL static (index.php).

 

Until someone logs in.

 

After that, the user has the ability to add to the content.

 

But what I want, is when they log it, it redirects them to a random page (the content in question) that is in a subfolder.

 

index.php

content/content1.php

V

V

V

content/contentn.php

 

So, after successfully logging in, I want it to redirect to one of the many .php files (at random) in the content folder.  By redirect, I mean I WANT the new URL to show to the user.

 

Unlogged in:

 

index.php (content1.php) - random

[REFRESH]

index.php (content5.php) - random

 

etc.

 

This works fine

 

Logged in:

content/content1.php - again, at random

 

I'm not sure if this issue even makes much sense.

 

I can get random images, but even then, the URL stays static.

Link to comment
https://forums.phpfreaks.com/topic/241242-redirect-to-random-page-in-a-sub-folder/
Share on other sites

This seems messy to me, but, I assume that in the way that is working that you just include the content pages in the index.php?  If so, then just check if they are loggedin and then do a header redirect:

 

index.php

// $random_page = whatever you do to get a random page
// $logged_in = whatever you do to determine if someone is logged in

if($logged_in) {
   header("Location: content/$random_page");
} else {
   include("content/$random_page");
}

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.