Jump to content

[SOLVED] log in problem


reshpu

Recommended Posts

this is my code:

 

<?php
session_start();

$con = mysql_connect("localhost","root");

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("registo", $con);

$user = $_POST[user];
$senha = $_POST[password];

$login = mysql_query ("SELECT * FROM person WHERE login='$user' AND password='$senha'") or die(mysql_error());

//Contar numero de registos encontrados no mysql
$num_resultados = mysql_num_rows($login);

//Se ouver pelo menos 1 resultado, quer dizer q os dados estao correctos
if($num_resultados)
{
header("Location: paginaseguinte.php");
//Isto depois é para usar nas paginas seguintes, para nao se poder ir para essas paginas se n tiver feito o login
$_SESSION['autorizado']   = "Sim";
}

else
{
echo "Login Errado</br>";
echo "<a href=login.htm>Voltar ao login</a>";
}
?>

 

is simple but is always give error "login errado"

Link to comment
Share on other sites

i would echo $user and $senha to make sure they conatin values - when i leave out quote marks (') in array key names i sometimes get an error.

what u did:

$user = $_POST[user];
$senha = $_POST[password];

what i would try:

$user = $_POST['user'];
$senha = $_POST['password'];

Link to comment
Share on other sites

the problem is:

 

my varibles dont work well.... so anyone can help me now.. i teste like this:

 

code:

<?php

session_start();

 

$con = mysql_connect("localhost","root");

 

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("registo", $con);

 

$user = $_POST[user];

$senha = $_POST[password];

echo $user;

 

 

ando dont print anything... plz help me  ???

Link to comment
Share on other sites

ok now all the code

 

form code :

 

<form method="post" action="login.php" style="height: 231px">

<div class="style2">

 

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<strong>

<span class="style8">Utilizador: </span><span class="style6">           

 

<input name="User" type="text" class="style6" style="width: 129px; font-family: Arial; color: #000000;" />       

<input name="Button1" type="submit" value="Entrar" style="width: 58px; " class="style7" align="middle" /><br />

</span>

</strong><span class="style5"><strong><br />

</strong><span class="style3"><strong>Palavra Passe:  

</strong></span></span> <input name="Password" type="password" class="style6" style="width: 129px" />       

<input name="Button2" type="reset" value="Limpar" style="width: 58px; font-family: Arial; color: #FFFFFF; background-color: #000000;" class="style7" /><br />

<br />

 

<a href="registo.htm" class="style7">

<input name="Button3" type="button" value="Registar" style="font-family: Arial; color: #FFFFFF; background-image: url('iiiiiiiiiiiiiiiiiiiiiiii.JPG');" /></a></div>

</form>

 

 

 

ok.. plz help me out

Link to comment
Share on other sites

im not sure, but i think that once upon a time (im my dark days of using asp  :P) i was making a form and put an "input" after the submit button and that messed everything up. try moving the submit button so its the very last element of the form. im not sure but i think that might work

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.