h4g Posted May 29, 2008 Share Posted May 29, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/107877-preg-match/ Share on other sites More sharing options...
DarkWater Posted May 29, 2008 Share Posted May 29, 2008 $reg = '<span class="nametext">(.*)</span>'; eregi($reg, $string, $name); $name = $name[0]; echo $name; Quote Link to comment https://forums.phpfreaks.com/topic/107877-preg-match/#findComment-553000 Share on other sites More sharing options...
h4g Posted May 29, 2008 Author Share Posted May 29, 2008 but what would i put in to make it get the content from another url? Quote Link to comment https://forums.phpfreaks.com/topic/107877-preg-match/#findComment-553008 Share on other sites More sharing options...
DarkWater Posted May 29, 2008 Share Posted May 29, 2008 $string = file_get_contents("URL"); Quote Link to comment https://forums.phpfreaks.com/topic/107877-preg-match/#findComment-553015 Share on other sites More sharing options...
h4g Posted May 29, 2008 Author Share Posted May 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/107877-preg-match/#findComment-553025 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.