Jump to content

Recommended Posts

Hello everyone,

 

I've been lurking these forums for the past several months, and have finally decided to register because I have a question that needs answering.

 

Although I have some experience programming and designing, I am relatively new to PHP and would like to know if creating a website like Stumbleupon.com would be possible using PHP?  What I am trying to do is create a website where there are certain categories, and certain webpages will be stored in each category. When a button is clicked, a random page among the list of websites I have stored is generated within the category.  Meanwhile, the top of the page remains the same while the bottom goes to an existing website.  If this sounds confusing, head on to stumbleupon.com and click the “Stumble” button at the top left and see how it works.  Furthermore, would creating a website like StumbleUpon use AJAX?  I don't know much about AJAX at all, but I can do research if need be.

 

This sounds do-able to me, but I am also very new to programming and would like some seasoned programmers to chime in with ideas or any helpful tips in creating a website like this.  Please guide me in any direction that'll make this project easier, thank you.

Link to comment
https://forums.phpfreaks.com/topic/165756-creating-a-website-like-stumbleupon/
Share on other sites

Yes this is quite possible to achieve with php,

 

You would need to use mysql or another type of database to store your url's and other data, once you had the url's you could set php to simply randomly select one from the database and load the url

 

Here's a very basic example of how to achieve this,

//FILE: index.php
<?php
//Stumbleupon example

@$do = $_REQUEST['do'];
$urls = array(
'http://www.google.co.uk',
'http://www.hotmail.com'
); //Build a list of urls
if(isset($do) or !$do){ //Just so we can reload a site when the stumble button is pressed
$max = count($urls); //Count the number of url's we have in our list
$stumble = rand(0,$max); //Randomly select a url from the list
require("taskbar.php"); //Load the bar at the top of the page and keep it there
echo "I picked $urls[$stumble]"; //Just an example to show what was picked.
echo "<br /><br /><iframe frameborder='0' noresize='noresize' style='position: absolute; background: transparent; width: 100%; height:100%;' src='$urls[$stumble]' />This Site uses iFrames</iframe>"; //Loads the site contents
}
?>
?>

//FILE: taskbar.php
<div align="center"><a href="?do=stumble" />Stumble</a></div><br /><br />

i would not recommend using the above code as it's open for attack but hopefully it will help you to understand how php can achieve what you are after,

 

You could use ajax to load the pages but it's  more of a fancy effect,

 

 

Hope it helps

 

Stuie

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.