how to get meta tags with php, but with html form
I got this PHPsrc
:
$tags = get_meta_tags('http://www.autostraddle.com');
echo "CMS is: ";
echo $tags['generator'];
This code is not user friendly; it's not ready for one online tool for my website, because I want create a simple service - CMS detector, and...
$tag = isset($_REQUEST['url']) ? get_meta_tags('url') : '';
<form action="index.php" method="post">
<input type="text" name="url" size="65" value="<?php echo $tag; ?>"/><br />
<input type="submit" value="Go!">
echo $tag['generator'];
I want create one online tool about detecting what CMS is, but I need this PHP script with HTML form because this will be used from users, and not only from me.
They must put any url, and then the script will perform as described to get the meta tag 'generator'; how do I get the meta tag 'generator'? I want only this meta tag.
Well, and how to do this with 'if else'? if there is meta tag generator do this, but if there is not such tag 'generator', then write any 'echo' message, e.g.
CMS is not known.
Well, this is simple PHP script, but I don't know how to create variables and how to get a URL; mayve with cURL?
Answer
Solution:
What you're struggling with is actually getting the user-side input from the POST superglobals. This is something you can try, but there are many ways to implement this. You could also use
method="SET"
and capture the user parameters from URL of theaction=""
file.Notice, in this case, the
action=""
parameter is empty. That means the PHP script will execute on the same page where the HTML form is. This might not be what you're trying to do, so if you need to redirect, add the PHP code to a separate file and add it to your website and to theaction=""
parameter.Give this a shot.