Kinopio Posted August 28, 2008 Share Posted August 28, 2008 I'm trying to make a webring for a network of sites but needed help with a couple things. So let's say there are 3 sites: 1) Site A 2) Site B 3) Site C Is there a way to generate a link that would take you from Site A to Site B, but if Site B was deleted, Site A's link would take you to Site C instead. I also want to do the reverse (for the "Previous" sites on the webring). I was thinking you can somehow use an array, but I'm not sure how it would know which site you were coming from and then redirect to the next one. I hope I said that the way I wanted. I'm still a beginner at PHP, so thanks in advance for any help! Link to comment https://forums.phpfreaks.com/topic/121628-webring/ Share on other sites More sharing options...
D3v 7oW Posted August 28, 2008 Share Posted August 28, 2008 So you want a code that if site a isnt up then the link is disabled? and if site b isnt up the link is disabled, etc... Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627434 Share on other sites More sharing options...
Kinopio Posted August 28, 2008 Author Share Posted August 28, 2008 I guess that was confusing. Basically what I want is if you were at Site A and clicked a link that sent you to www.mywebsite.com/next.php, that page (next.php) would redirect you to Site B. If you were at Site B and you clicked the same link, www.mywebsite.com/next.php, it would redirect you to Site C and so on. Forget about the whole deleted thing. Maybe it's not even possible, so I don't know. I'm still a fledgling PHP user. Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627445 Share on other sites More sharing options...
benphelps Posted August 28, 2008 Share Posted August 28, 2008 Maybe: <?php $fp = fsockopen("www.example.com", 80, $errno, $errstr, 30); if(!$fp){ // site is down, use next site } else { // site is up, continue to site } ?> I have not tested this, but I think it will get you started with the site deleted thing. This might work for the next.php <?php $siteID = $_GET['siteID']; $nextsite = $siteID++; $newurl = 'www.example.com/next.php?siteID='.$nextsite.''; ?> This will work for a numerical web ring, where the users starts at site 1 and stops at the last site. This is very basic and would require some more code to work, but I think this is the basics. You might be able to use cookies if the users decides to browse the site before clicking the next site link. Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627465 Share on other sites More sharing options...
Kinopio Posted August 28, 2008 Author Share Posted August 28, 2008 Uh, does this look like I'm on the right track, sorta? <?php $siteID[0] = 'http://example1.com'; $siteID[1] = 'http://example2.com'; $siteID[2] = 'http://example3.com'; $siteID = $_GET['siteID']; $nextsite = $siteID++; $newurl = 'http://example.com/next.php?siteID='.$nextsite.''; echo "<meta http-equiv=\"refresh\" content=\"3; url={$newurl}\">"; ?> I don't understand how to get the site's current id though. =\ You might be able to use cookies if the users decides to browse the site before clicking the next site link. How do you make cookies. o_o Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627493 Share on other sites More sharing options...
Kinopio Posted August 28, 2008 Author Share Posted August 28, 2008 Anyone have any ideas? Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627781 Share on other sites More sharing options...
BlueSkyIS Posted August 28, 2008 Share Posted August 28, 2008 Uh, does this look like I'm on the right track, sorta? no. you're defining array elements for $siteID, then overwriting $siteID as a scalar: <?php $siteID = array(); // you should have this line to define the array $siteID[0] = 'http://example1.com'; // element added to array $siteID[1] = 'http://example2.com'; // another element added to array $siteID[2] = 'http://example3.com'; // another element added to array $siteID = $_GET['siteID']; // $siteID is re-defined as a scaler containing $_GET['siteID']. the array you loaded is now gone. $nextsite = $siteID++; $newurl = 'http://example.com/next.php?siteID='.$nextsite.''; echo "<meta http-equiv=\"refresh\" content=\"3; url={$newurl}\">"; ?> Link to comment https://forums.phpfreaks.com/topic/121628-webring/#findComment-627793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.