Jump to content

preg match?


h4g

Recommended Posts

I think this is preg match, but I'm not sure how to do it

 

I have a file called form.php, here's an example of the code

<form method="POST" action="grabber.php">
<input type="text" name="id" value="" maxlength="17">
<input type="submit" value="hit it ">
</form>

 

what i want to do with "grabber.php" is this..

just $_GET['id'] and then when we have $id,

i want the script to get this information from a certain website (like http://example.com/profile.php?user=$id)

<span class="nametext">Some Name</span>
<a id="ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage" href="http://example.com"><img border="0" alt="" src="http://example.com/example.png" /></a>

 

I want grabber.php to get the text in-between

<span class="nametext"></span>

and display the text

 

and the picture in-between

<a id="ctl00_Main_ctl00_UserBasicInformation1_hlDefaultImage" href="http://example.com"></a>

also display that

 

any ideas?

Link to comment
https://forums.phpfreaks.com/topic/107877-preg-match/
Share on other sites

okay this works-

<?php
$id = $_GET['id'];
$string = file_get_contents("http://profile.myspace.com/index.cfm?fuseaction=user.viewProfile&friendID=$id");
$reg = '<span class="nametext">(.*)</span>';
eregi($reg, $string,  $name);
$name = $name[0];
echo $name;
?>

 

but it shows the name at the top, then the rest of the other page at the bottom

 

 

Link to comment
https://forums.phpfreaks.com/topic/107877-preg-match/#findComment-553025
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.