reshpu Posted March 6, 2007 Share Posted March 6, 2007 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 More sharing options...
iceman400 Posted March 6, 2007 Share Posted March 6, 2007 well correct me if im wrong, but shouldnt mysql_connect() also contain a password? and is your using mysql > 4 all your code should be mysqli Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200675 Share on other sites More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 mysql_connet() dont have pass in my computer XD... so the program connect but never do the login.... Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200677 Share on other sites More sharing options...
Kano Posted March 6, 2007 Share Posted March 6, 2007 HI there, should you select statements where ....... = ('$_post[]'); ?? Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200678 Share on other sites More sharing options...
Kano Posted March 6, 2007 Share Posted March 6, 2007 oops my mistake you created variables previously Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200679 Share on other sites More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 nop.... i do the same sh*** to the register.. and works now the login.... Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200682 Share on other sites More sharing options...
iceman400 Posted March 6, 2007 Share Posted March 6, 2007 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 https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200683 Share on other sites More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 in beggin i have that $user = $_POST['user']; $senha = $_POST['password']; i take off... is the same.... one big problem.... Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200684 Share on other sites More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 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 More sharing options...
iceman400 Posted March 6, 2007 Share Posted March 6, 2007 errm...can you post the code for the login form? Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200692 Share on other sites More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 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 More sharing options...
iceman400 Posted March 6, 2007 Share Posted March 6, 2007 im not sure, but i think that once upon a time (im my dark days of using asp ) 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 More sharing options...
reshpu Posted March 6, 2007 Author Share Posted March 6, 2007 rsolve: my problem is: $user = $_POST['user']; $senha = $_POST['password']; resolve: $user = $_POST['User']; $senha = $_POST['Password']; sry guys... ;D Link to comment https://forums.phpfreaks.com/topic/41425-solved-log-in-problem/#findComment-200698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.