Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I would like to know how to force everyone to see my Main Page
Old 01-12-2008, 09:54 PM I would like to know how to force everyone to see my Main Page
Junior Talker

Posts: 3
Name: Jolt
Trades: 0
Hello,

I run a small forum for myself and friends. I am glad they use it and it is coming along great. My only concern is that my main page does not get nearly as many hits as my forum. Is there anyway to prevent viewers from automatically typing in the URL to our forums? Is it possible to automatically redirect them to the main page and force them to click the Forums link via the main page?

Thank You

Jolt
Jolt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-12-2008, 10:44 PM Re: I would like to know how to force everyone to see my Main Page
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
If you set a session variable which indicates if the home page has been set and redirects to the home page until it's set, then that should do what you want.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-12-2008, 11:17 PM Re: I would like to know how to force everyone to see my Main Page
Junior Talker

Posts: 3
Name: Jolt
Trades: 0
Hey, thanks for your response. Do you mind showing me an example? I am new to the whole PHP coding. I knew a PHP code would get it done.
Jolt is offline
Reply With Quote
View Public Profile
 
Old 01-12-2008, 11:20 PM Re: I would like to know how to force everyone to see my Main Page
cwboaze's Avatar
Novice Talker

Posts: 10
Name: Chris Boaze
Location: Online - Virginia
Trades: 0
you could write in php to block as on the referrer, ex: if they came from http://yourdomain.com and you only want people from http://yourdomain.com/index.php then add all the ones you want to block in the array and the else will run if they didn't come from what you have listed to block
PHP Code:
 <?php
$deny 
= array("http://yourdomain.com/index.php""AnotherRefferalAddressToblock");
if (
in_array ($_SERVER["HTTP_REFERER"], $deny)) {
header("location: http://www.google.com/");
exit();
} else{
header("location: http://www.yahoo.com/");
exit();
?>
There are so many ways of doing this. pm if you need personal help.

+

Sessions are find for this situation!, but there are ways around unproper sessions if you don't code them properly.
__________________
-------------
Thanks, CB-The-One

Please login or register to view this content. Registration is FREE

Last edited by cwboaze; 01-12-2008 at 11:26 PM..
cwboaze is offline
Reply With Quote
View Public Profile Visit cwboaze's homepage!
 
Old 01-12-2008, 11:21 PM Re: I would like to know how to force everyone to see my Main Page
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
On the homepage add this at the VERY top:

PHP Code:
<?php
session_start
();
$_SESSION['homepage_shown'] = "yes";
?>
On EVERY other page, add this at the top:
PHP Code:
<?php
session_start
();
if (
$_SESSION['homepage_shown'] != "yes") {
  
header("Location: index.php");
  exit();
}
?>
Assuming your homepage is at index.php
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-12-2008, 11:22 PM Re: I would like to know how to force everyone to see my Main Page
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
Originally Posted by cwboaze View Post
you could also write in php to only allow that visitor to visit that page from another page the referrer
Problem with that is that a number of people have security things installed in their browser which hide the referrer, so they wouldn't be able to access any other page on your site but the homepage.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-13-2008, 12:39 AM Re: I would like to know how to force everyone to see my Main Page
Junior Talker

Posts: 3
Name: Jolt
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
On the homepage add this at the VERY top:

PHP Code:
<?php
session_start
();
$_SESSION['homepage_shown'] = "yes";
?>
On EVERY other page, add this at the top:
PHP Code:
<?php
session_start
();
if (
$_SESSION['homepage_shown'] != "yes") {
  
header("Location: index.php");
  exit();
}
?>
Assuming your homepage is at index.php
Maybe this is my novice PHP mind acting up, but I did exactly as you said and had no luck at all.

I placed the above code in my index.php and the latter in my Forums/index.php.

It doesn't work.
Jolt is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 12:41 AM Re: I would like to know how to force everyone to see my Main Page
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
It's probably that you need to change the header() function as index.php when in a subfolder will still refer to the subfolder. You may want to try the full URL for redirection:
PHP Code:
 <?php
session_start
();
if (
$_SESSION['homepage_shown'] != "yes") {
  
header("Location: http://www.mydomain.com/index.php");
  exit();
}
?>
Or
PHP Code:
 <?php
session_start
();
if (
$_SESSION['homepage_shown'] != "yes") {
  
header("Location: ../index.php");
  exit();
}
?>
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-13-2008, 12:50 AM Re: I would like to know how to force everyone to see my Main Page
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Honestly.. Why would you want to do that? Think about it this way. Would you rather take the 5 minute detour or go straight to the road you want and save 4 extra minutes? The whole idea of your site should be to give users what they want. Forcing them to see what they obviously don't want to see will just make them mad and make them want to leave. The Internet is all about convenience. People can get the same data the Internet has to offer in books but they can get that info faster. I hope I've said enough to change your mind but if I haven't really think it through. I know of many sites who do stuff like this and have lost millions of users every time they did it. Also if there's info on the front page you want them to see then just put it up on the forum.. If that's not your reason then there should be absolutely no reason for them to go straight to the homepage every time.. One last point - Your users have gone through the trouble to either bookmark the forums URL or usually flat out memorize it. If they're willing to go through that (I know it doesn't sound like much but it is) then they obviously have a good reason to skip your homepage. Maybe no useful content on your homepage? A link to your site would be pretty good :S.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications

Last edited by Mattmaul1992; 01-13-2008 at 12:52 AM..
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 12:56 AM Re: I would like to know how to force everyone to see my Main Page
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
I gotta say that even though I've provided you the code, I agree 100% with Matt. I hate it when sites don't let me do what I want and have stopped going to sites for much less.

Matt: TK is coming your way!
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-13-2008, 01:22 AM Re: I would like to know how to force everyone to see my Main Page
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Quote:
Originally Posted by JeremyMiller View Post
I gotta say that even though I've provided you the code, I agree 100% with Matt. I hate it when sites don't let me do what I want and have stopped going to sites for much less.

Matt: TK is coming your way!
Thanks and ditto .
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I would like to know how to force everyone to see my Main Page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33193 seconds with 12 queries