2 Home pages?

Discussion in 'PHP' started by webber09, Sep 5, 2012.

  1. #1
    Hi everyone,

    So im looking to get 2 homepages, the first one will be to greet visitors and offer them to go to another one of my sites or stay on the current site, i will be doing this by having 2 basic html links. And the other page will be if they clicked to stay on the site, so the proper home page of the current site. I want to avoid creating 2 separate pages which would cause the url to be something like example.com/home

    Is there any way of doing this via some php on the link to stay on this site or is it impossible resulting in me having to use the /home way in the url? :confused:

    Thanks in advance =]
     
    webber09, Sep 5, 2012 IP
  2. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #2
    Ajax would do this very nicely. I can code it up for $10. It would be one html page and I can do it now. Paypal payment when done.
     
    DomainerHelper, Sep 5, 2012 IP
  3. affishare

    affishare Member

    Messages:
    82
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    30
    #3
    you can make popup window in your homepage where people need to choose what they want
     
    affishare, Sep 5, 2012 IP
  4. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #4
    Yeah because 99% of the world don't use popup stoppers. *sarcasm*
     
    DomainerHelper, Sep 5, 2012 IP
  5. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #5
    would it be possible to do this via setting a cookie on the link and if the cookie is set, it displays the home page, if not it shows the 2 links?
     
    webber09, Sep 6, 2012 IP
  6. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #6
    Why would you want to do that? What about browsers blocking cookies?

    You'd still need either 2 to 3 pages or Ajax.... whether you use cookies or php sessions.

    Cookies are packets of data stored in the users browser. A cookie does not decide what page to show. You need a script to set/read cookies.
     
    DomainerHelper, Sep 6, 2012 IP
  7. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #7
    So would something like this work?

    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Ajax Set Get Cookie</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready( function() {
    		$("#setcookie").click(function() {
    			if($("#cookievalue").val() != '')
    				setCookie( $("#cookievalue").val() );
    		});
    		$("#getcookie").click(function() {
    			getCookie();
    		});
    	 });
    function setCookie(value)
    {
    	$.get("../cookie.php", { cookie: value}, 
    		function(data){
    			alert(data);
    		}
    	);
    }
    function getCookie(value)
    {
    	$.get("../cookie.php", { }, 
    		function(data){
    			alert(data);
    		}
    	);
    }
    </script>
    </head>
    <body>
    <div align="center"> Cookie:
      <input type="text" id="cookievalue" value="" />
      <br />
      <a href="#"><input type="button" id="setcookie" value="Set Cookie"  /></a>
      <a href="http://othersite.co.uk">Other link</a>
    </div>
    </body>
    </html>
    
    HTML:
    with

    
    <?php
    if($_GET['cookie']!='')
    {
    	setcookie("cookie", $_GET['cookie']);
    	echo 'set cookie: ' . $_GET['cookie'];
    }
    else
    	echo 'get cookie: ' . $_COOKIE["cookie"];
    ?>
    
    PHP:
     
    webber09, Sep 6, 2012 IP
  8. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #8
    WTF? lol

    Why dont you just have it chang ethe DIV content based on the button clicked? Cookies not needed. You are overthinking it.
     
    DomainerHelper, Sep 6, 2012 IP
  9. webber09

    webber09 Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #9
    so could i use the above HTML with the php as:

    
    <?php
    if($_GET['cookie']!='')
    {
        setcookie("cookie", $_GET['cookie']);
        echo 'Homepage 2 content';
    }
    else
        echo 'Homepage with links';
    ?>
    
    PHP:
     
    webber09, Sep 6, 2012 IP
  10. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #10
    DomainerHelper, Sep 6, 2012 IP