posting contents of td in sperate page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mgkeeper
Forum Newbie
Posts: 5
Joined: Mon Aug 14, 2006 1:15 pm

posting contents of td in sperate page

Post 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
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Why bother trying to parse a page you generated? Just generate a new page from the same sources of the first page. :?
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post by nincha »

hehe, that is true.
Mgkeeper
Forum Newbie
Posts: 5
Joined: Mon Aug 14, 2006 1:15 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Mgkeeper
Forum Newbie
Posts: 5
Joined: Mon Aug 14, 2006 1:15 pm

Post 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)
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

Post 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.
Last edited by nincha on Mon Aug 14, 2006 2:13 pm, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Having a user/pass doesn't necessarily give you the permission from the original website to use their content on your site.
Mgkeeper
Forum Newbie
Posts: 5
Joined: Mon Aug 14, 2006 1:15 pm

Post 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.
Mgkeeper
Forum Newbie
Posts: 5
Joined: Mon Aug 14, 2006 1:15 pm

Post 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
Post Reply