The error occurs because you are probably sending a form without method="POST"
or the attribute name=""
in the input
is wrong.
To run the <form>
must 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 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 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);
}
Yes still an error does not access the login but has data in it , may be database error
– brunoangola
what mistake you made?
– Sr. André Baill
Undefined variable: login in C: xampp htdocs Techphp profile.php on line 7 This shows the text saying that the login is empty, but has the login Cod in the database
– brunoangola
modify as André suggested..
– Daniel Omine