0

I have a site lets name it http://mysite.com/index.php which is my main site with all the information and I want to have another page which is something like http://mysite.com/index.php?=premium and in this premium page will be totally new whole page. Which means not the same title or not have anything relate to the index.php page.

The reason is that I don't want my visitors to go directly to the premium page so they have to come to the index.php page first then click it from there.

Is that possible this way?

@knittl well not sure if my question was cleared

but what is actually happening now that the above code can get me to the premium page fine with no problem

but inside the premium page include many div class and I have this in the premium page

<?php
if(!isset($_GET['ch'])){ 
    $ch = 1; 
} else { 
    $ch = $_GET['ch']; 
}

if ($ch == 1) {
echo "<div class='player_live_server_info'> 

so what happen now that I have this

<li><a href="tv.php?page=premium?ch=1"><img src="live_img/ch_5.jpg"></a></li>

I don't know if I do it right or wrong but It just redirect back to the normal page.

Ali
  • 9,997
  • 20
  • 70
  • 105
  • The button is in the index.php and I want people to click to go to the new page like Wordpress when they go to next page but I just want it to be totally new page if that is possible – Ali Jun 19 '11 at 15:37
  • the can just bookmark your premium page and be there without visiting your "normal" page – knittl Jun 19 '11 at 15:37
  • Yes they can do that as I thought so, but many people will not really thought of that since my site is a mobile site (iPhones) – Ali Jun 19 '11 at 15:38
  • @knittl not if you check referer then redirect if not from `http://mysite.com/index.php` index.php?=premium is missing the GET parameter – Lawrence Cherone Jun 19 '11 at 15:39
  • @lawrence: referer headers could be stripped by firewalls … – knittl Jun 19 '11 at 15:43
  • being connected to a wifi network, why not? and apple could decide to disable sending of referer header – knittl Jun 19 '11 at 15:58

2 Answers2

3
<?php if(isset($_GET['page']) && $_GET['page'] == 'premium') {
// this is the premium version, only visible when called as index.php?page=premium
?>

<html>
<head><title>you are on the fancy premium page</title></head>
<body>
  <h1>your premium page</h1>
</body>
</html>

<?php } else {
// this is the normal page with a link to the premium version
?>

<html>
<head><title>you are on the lame normal page</title></head>
<body>
  <h1>your normal page</h1>
  <p>
    <a href="?page=premium">click here to go to our premium page</a>
  </p>
</body>
</html>

<?php } ?>
knittl
  • 246,190
  • 53
  • 318
  • 364
  • also `if($_GET['page'] == 'premium' && $_SERVER['HTTP_REFERER']=='http://mysite.com/index.php')` – Lawrence Cherone Jun 19 '11 at 15:44
  • @lawrence: see answers to questions [HTTP_REFERER coming back with NULL, key does not exist in $_SERVER](http://stackoverflow.com/q/5551094/112968) and [Alternative to “Referer” Header](http://stackoverflow.com/q/3546097/112968) as well as [Internet Explorer Does Not Send Referer Header](http://www.vanimpe.eu/blog/2008/08/27/internet-explorer-does-not-send-referer-header/) – knittl Jun 19 '11 at 15:51
  • I have place this code and place all my html instead but it doesn't change the whole or did I misunderstood anything? – Ali Jun 19 '11 at 15:53
  • what exatctly is not working? when the page is called without the `?page=premium` query string (i.e. the GET parameter `page` remains unset), then the default page is served. if the parameter is set, the first if will be executed and you should see your "premium" page – knittl Jun 19 '11 at 16:01
  • ok how about this let me explain this way I currently have http://mysite.com/premium.php and also I have my main site which is http://mysite.com/index.php but instead of those people who go directly to premium.php now I want to delete the file premium.php and just include my whole codes in the index.php but only display them when they click the button and when they click the button it should be totally new page with css and all the codes if that is possible – Ali Jun 19 '11 at 16:09
  • 1
    @ali: simply use the code template i've posted in my answer. the top part is the premium page, the lower part (else) is the normal page. when the page is called as `index.php?page=premium` only the top part (if) will be executed. if called in any other way, you only see the bottom part (else) – knittl Jun 19 '11 at 16:14
  • sorry it was my fault I was actually having another code in the same page that is why isn't working – Ali Jun 19 '11 at 16:33
  • @knittl I have another question in the premium page I have php function if isset for about 50 new div class on each of the clicks and it does not work because the URL will keep changing and redirect back to the normal page what can I do to fix this? – Ali Jun 19 '11 at 18:35
  • @ali: you have to add the get parameter `page=premium` to every request to the page of course, otherwise you will be redirected to your normal page again. have you considered using cookies or sessions to store if a user can already see the premium page? – knittl Jun 19 '11 at 18:38
  • @knittl well not sure if my question was cleared but what is actually happening now that the above code can get me to the premium page fine with no problem but inside the premium page include many div class and I have this in the premium page so what happen now that I have this
  • I don't know if I do it right or wrong but It just redirect back to the normal page. – Ali Jun 19 '11 at 18:44
  • @knittl I have include it to the top post so it will be easy to look at – Ali Jun 19 '11 at 18:45
  • 1
    @ali: for multiple get parameters, you have to chain them using `&`. escaped for html output an anchor tag would look like this: `click me`, otherwise only one of the parameters is passed to your php script (depending on browser and web server (configuration)) – knittl Jun 19 '11 at 18:47