3
I have a script simple that makes a user of mine website can view your data on a page, for example: name, email, age, image. See script down below:
<html>
<head>
<title> Login de Usuário </title>
</head>
<body>
<form method="POST" action="login.php">
<label>pnome:</label><input type="text" name="pnome" id="pnome"><br>
<label>nomec:</label><input type="text" name="nomec" id="nomec"><br>
<input type="submit" value="entrar" id="entrar" name="entrar"><br>
<a href="cadastro.html">Cadastre-se</a>
</form>
</body>
</html>
This is the PHP that makes the login:
<?php
$login = $_POST['pnome'];
$entrar = $_POST['entrar'];
$senha = md5($_POST['nomec']);
$connect = mysql_connect('localhost','root','123');
$db = mysql_select_db('banco_cliente');
if (isset($entrar)) {
$verifica = mysql_query("SELECT * FROM jogo WHERE pnome = '$pnome' AND nomec = '$nomec'") or die("erro ao selecionar");
if (mysql_num_rows($verifica)<=0){
echo"<script language='javascript' type='text/javascript'>alert('Login e/ou senha incorretos');window.location.href='login.html';</script>";
die();
}else{
setcookie("pnome",$pnome);
header("Location:Pasta/comeng2.php");
}
}
?>
This is the page that will show the data of login if he logged on:
<?php
$pnome_cookie = $_COOKIE['pnome'];
if(isset($pnome_cookie)){
echo"Bem-Vindo, $pnome_cookie <br>";
echo" $nomec_cookie <br>";
echo" $img_cookie <br>";
echo" $email_cookie <br>";
echo" $idade_cookie <br>";
echo"Essas informações <font color='red'>PODEM</font> ser acessadas por você";
}else{
echo"Bem-Vindo, convidado <br>";
echo"Essas informações <font color='red'>NÃO PODEM</font> ser acessadas por você";
echo"<br><a href='login.html'>Faça Login</a> Para ler o conteúdo";
}
?>
Then only returns me the welcome information: "So-and-so this information can be accessed by you!" But the others does not show:
These do not show in the echo
:
nomec
img
email
idade
I tried to change the select
from the example table:
$verifica = mysql_query("SELECT * FROM jogo WHERE pnome = '$pnome' AND nomec = '$nomec' AND img = '$img' AND email = '$email' AND idade = '$idade'") or die("erro ao selecionar");
But gives error. How to do not give error and return all user data?
Where do they come from
$pnome
and$nomec
?– user25930
of a form in html, which is used to log in has no password.
– adailton moraes
Add the form code to your question, the names may be wrong
– Maicon Carraro
please add the error message
– Pedro Sanção
no error message only is not returning me this data: name img email age
– adailton moraes