The error occurs because you are probably sending a form without method="POST"
or the name=""
attribute in input
is wrong.
To work with <form>
should be something like:
<form method="POST" action="perfil.php">
<input type="text" name="login" value="">
<input type="submit" value="Buscar">
</form>
However by your query I suspect that you are not using a form but rather a GET method, probably a link with <a href="perfil.php?login=usuario">
Links do not use POST method, they use GET method, so the correct one is this:
$login = NULL; //Declaramos a variavel
if(false === empty($_GET['login'])){//Se existir define em login e não for vazia
$login = $_GET['login'];
} else {//Se não existir ou for vazia emite um erro
echo "Login Vazio.";
}
if ($login) {//Se a variável existir executa a query
$sql = mysql_query( "SELECT * FROM usuario WHERE login='{$login}'") or print mysql_error();
$linha = mysql_fetch_array($sql);
}