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
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
Share on other sites

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.