Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question

closed as off topic by Iain May 19 '12 at 21:23

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

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. – Iain May 19 '12 at 21:25

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

    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" />
} 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.

share|improve this answer
yeah , thanks a lot – Dima Savva May 19 '12 at 21:07
Sure, no problem. – alexpja May 19 '12 at 21:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.