-1

I have a task.

One input:

input type='text' id='url' name='url'

One button:

button id='go'

and one div.

User writes a site in that input and onclick i must show title of that site

How can i do that ?

1
  • This question is off topic for serverfault. It may be on topic for Stackoverflow but check their faq and search their site before asking there. They also don't like give me teh codez type questions much though.
    – user9517
    May 19, 2012 at 21:25

1 Answer 1

1

From what you told me, here's some code.

<?php
    if (!isset($_GET['go'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET" />
<input type="text" name="url" id="url" /><br /><input type="submit" name="go" id="go" />
</form>
<?php
} else {
$url = $_GET['url'];
$file = file($url);
$file = implode("",$file);

if(preg_match("/<title>(.+)<\/title>/i",$file,$m)) {
    print "The title of $url is <b>$m[1]";
} else {
    print "The page doesn't have a title tag";
}
}
?>

This downloads the file into the PHP memory and gets the information between the title tags.

0

Not the answer you're looking for? Browse other questions tagged .