Page 1 of 1

posting contents of td in sperate page

Posted: Mon Aug 14, 2006 1:23 pm
by Mgkeeper
First off, let me apologize for this incoherent post that will follow. I am no php expert, I am just learning. I already know what I want to do, I just need to learn the means to do it. So here goes:

lets say I have a page called info.php

on this page, things are displayed like:

Name:
bob


and when you view source on the page, it looks something like this:

<th>Name:</th>
<td name=name1> bob </td>

and lets say I have a seperate page called output.php

is there a way i can have output.php display the contents of the td named "name1"?

I know if the td was set a a variable like $name it would be simple. But I am unsure how/if I can have php display the contents of a td tag based on its name in html

Posted: Mon Aug 14, 2006 1:31 pm
by nincha
if you have access to the file, open and parse it.
otherwise, theres a php defined function that reads web pages and you can parse off that, http://php.net for ref.

Posted: Mon Aug 14, 2006 1:42 pm
by feyd
Why bother trying to parse a page you generated? Just generate a new page from the same sources of the first page. :?

Posted: Mon Aug 14, 2006 1:47 pm
by nincha
hehe, that is true.

Posted: Mon Aug 14, 2006 2:00 pm
by Mgkeeper
hmm, well I dont have access to the file itself, and whats worse is I think its dynamically generated.

Heres what I have so far:

<?php

$url = “https://<?php echo $_POST["name"] ?>”;
$content = readfile($url);


?>

So basically, I have a form that takes you to this page, and inserts the forms input as the url after https://

From the article i got this from, it tells me that it stores the webpages information in $content, is this correct?

If so, how would I get php to display (using my previous example) the contents of the td tag named "name1" contained within that page?

P.S. I really appreciate you guys for offering advice, I expected you to flame me to death for being such a novice :P

Posted: Mon Aug 14, 2006 2:03 pm
by feyd
Do you have permission to use their pages on your site?

If you read the documentation on readfile() you'll notice it returns an integer, not a string.

Posted: Mon Aug 14, 2006 2:06 pm
by Mgkeeper
ahh, I see. I also saw some documentation on fopen, but I did not see anything that explained how to pull certain info from the file.

Also, I have a user/pass to access the file in question, however, I do not have FTP access (that would make this ALOT easier lol)

Posted: Mon Aug 14, 2006 2:08 pm
by nincha
use

$content=file_get_contents("url");

can you echo $content and tell me what it is? remember if it has html tags then go to view source to see the exact output.

Posted: Mon Aug 14, 2006 2:09 pm
by feyd
Having a user/pass doesn't necessarily give you the permission from the original website to use their content on your site.

Posted: Mon Aug 14, 2006 2:15 pm
by Mgkeeper
Do you mean whether the server the files are on allows for fopen? im not sure, but so far, im not seeing errors.

if you mean to I have permission from the developers to use their files in this way, I do. However, there is sensitive information available to me if I were to get FTP access, thats why they cant give it.

<?php

$handle = fopen("https://<?php echo $_POST["name"] ?>", "r");

?>

so does this command store the contents of https://(whatever i submit on the form) in $handle ? or is there anyther command within fopen I need to use to do this.

Posted: Mon Aug 14, 2006 2:29 pm
by Mgkeeper
ps, sorry i didnt see your post nincha, I used your code to do this:

<?php

$content=file_get_contents("http://yahoo.com");

echo $content

?>

it works great, the problem is, it doesnt seem to work with Secure URL's, is there an option for file_get_contents that supports SSL?

there is a php info on the server:

http://godsannointed.org/phpinfo.php

its showing curl and openssl as supported.

I tried modifying the link to ssl:// instead of https:// but that didnt work