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? Thanks in advance =]
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.
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?
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.
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:
WTF? lol Why dont you just have it chang ethe DIV content based on the button clicked? Cookies not needed. You are overthinking it.
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:
Avoid cookies is the point: http://www.codeproject.com/Articles/1309/Changing-content-on-the-fly-using-JavaScript to remember use a session, not cookie.