how to replace a form w input from variable

jlknauff

New member
Aug 25, 2008
237
1
0
I'm working on a dashboard to monitor several stats for several of our in-house and client websites...I found a script to grab the Google PR, but it uses a form, which I want to replace. In the end, the data will be passed from a variable, but while I'm trying to get it working, it's just hard coded in. Here is the part of the code from the original script that contains the form:

Code:
if ((!isset($_POST['url'])) && (!isset($_GET['url']))) { echo '<form action="" method="post"><input name="url" type="text"><input type="submit" name="Submit" value="Get Pagerank"></form>'; } if (isset($_REQUEST['url'])) { echo pagerank($_REQUEST['url']); }

I've gone through a lot of trial and error, and here is where I am, though it is obviously wrong:

Code:
$action = "";
$method = "POST";
$ref = "";
$data_array['url'] = "msn.com";
$data_array['Submit'] = "Get Pagerank";
$response = http($target=$action, $ref, $method, $data_array, EXCL_HEAD);
if ((!isset($_POST['url'])) && (!isset($_GET['url']))) {$response;}
if (isset($_REQUEST['url'])) { echo pagerank($_REQUEST['url']); }

Am I at least on the right track? I know it can be done...any idea how?
 


You are over thinking this. I think all ya need is this
$url = 'msn.com';
echo pagerank($url);

Your 2nd to last line doesn't do anything at all by the way. The http function is executed when you assign it into a variable, before your !isset conditional statement. Inside that statement $response; doesn't do a thing.
 
This question makes my head hurt, what your doing doesn't even make any sense!

You ever hear of cURL? You need to read my nobbie tutorial on scraping. Although not directly related, I'm sure you'll pick up a thing or three on how to accomplish this:

Noobie Scraping Guide | MadPPC
Noobies Guide on How to Scrape: Part 2 – URLs, URL Variables, and using Live HTTP Headers | MadPPC
Noobies Guide on How to Scrape: Part 3 – Basics of Assessing Your Target | MadPPC
Noobies Guide on How to Scrape: Part 4 – cURL | MadPPC
Noobies Guide on How to Scrape: Part 5 ? A Basic Scraper | MadPPC
 
You should probably start with the unmodified PR script, include it in your main script/site/whatever ( php.net/include ) and then just call the function: pagerank(your_url) where your_url is the variable, ie. msn.com or whatever.

Trying to further edit a possibly somewhat sketchy script is just going to get you in trouble...