Jump to content

Recommended Posts

I am trying to modify a script which retrieves a websites statistics like page rank, inbound links etc.

 

Originally the script displayed the statistics on the same page where the user inputs his/her website url to be

checked.

 

I want the script to transfer the user to another page (/results.php) so that the statistical results are

displayed on a seperate page.

I have tried and tried however I cannot figure out how to do it. This should be quite an easy question

to php users.

 

Please help me..

 

Here are the 3 scripts which are related to this problem. (there are other scripts which retrieve the statistics

but they are not related with my problem so I will not include them.):

 

***** index.html *****

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>PageRank Script</title>

<link href="./css/main.css" rel="stylesheet" />

<script language="javascript" type="text/javascript" src="./js/main.js"></script>

</head>

<body>

        <? // Call results.php to be displayed after user clicks submit ?>

<form action="./results.php" method="post" id="form">

       

<h1>Check Your PageRank!</h1>

<label for="url" title="Enter the URL of the website you want the PageRank for">URL:</label><br />

           

<input type="text" name="url" id="url" value="http://" class="input" /><br />

<input type="submit" value="Get PageRank!" class="button" /><br />

<img src="img/loading.gif" id="loading" />

            <div id="results"></div>

</form>

</body>

</html>

 

 

 

***** results.php *****

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

 

</head>

 

<body>

 

<?php

 

error_reporting(E_ALL ^ E_NOTICE);

 

// Check whether user inputted URL contains 'http'

if (trim($_GET['url']) && trim($_GET['url']) != 'http://') {

include './php/rank.class.php';

$url = get_magic_quotes_gpc() ? urldecode(stripslashes($_GET['url'])) : urldecode($_GET['url']);

 

$rank = new rank($url);

        // Set up array containing all statistics details

$s = array('$url', '$pagerank', '$alexa_rank', '$backlinks', '$msn', '$yahoo');

       

        // Call rank.class.php and obtain values for statistics details

$backlinks = ceil(($rank->backlinks['google'] + $rank->backlinks['yahoo'] + $rank->backlinks['msn'] + $rank->backlinks['altavista'] + $rank->backlinks['alltheweb']) / 5);

$r = array($rank->url, $rank->pagerank, $rank->format_number($rank->alexa_rank), $rank->format_number($backlinks), $rank->format_number($rank->backlinks['msn']), $rank->format_number($rank->backlinks['yahoo']));

       

 

        // Send statistics details to be displayed in template.html

echo str_replace($s, $r, file_get_contents('template.html'));

} else {

echo 'Enter a valid URL';

}

 

print ("PageRank for this site is: $r[1]");

?>

 

</body>

</html>

 

 

 

 

***** template.html *****

 

 

<table>

<tr>

<td class="left">PageRank</td>

<td class="right">$pagerank</td>

</tr>

<tr>

<td class="left">Alexa Rank</td>

<td class="right">$alexa_rank</td>

</tr>

<tr>

<td class="left">Back Links</td>

<td class="right">$backlinks</td>

</tr>

<tr>

<td class="left">MSN Search Results</td>

<td class="right">$msn</td>

</tr>

</table>

WEll im not gonna lie but i dont really feel like looking through this entire script but it looks like you are trying to use php variables within html... so you would need to do something like this

   <tr>
      <td class="left">Back Links</td>
      <td class="right">$backlinks</td>
   </tr>

change to this for all of the variables you want to show

   <tr>
      <td class="left">Back Links</td>
      <td class="right"><?php echo $backlinks; ?></td>
   </tr>

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.