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
https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/
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
https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200689
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
https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200695
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
https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200697
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.