VinnyCP Posted May 20, 2010 Share Posted May 20, 2010 Hey yo, peeps... I really need some help now... I was requested to make a simple contact agenda, and I started programming yesterday. I finished (at least I thought I did) yesterday, the login method. And it was working! O_O But today, I logged in the agenda using IE 8. Everything was ok. Then I opened Google Chrome and Firefox (both very popular in this enterprise), and they were not loggin in! I checked the login form. The variable for username is "usuario" and for password is "senha". Everything is right in my 'login.php'. If you guys wish to see the code, it is something like that: ('autentica.php', the form action) session_start(); include "funcoes.php"; //This is a file with my functions (OO disguise ) conectaBanco(); //This function conects to the database. $usuario=$_POST["usuario"]; $senha=md5($_POST["senha"]); //I think the cryptografy is ok. The pass is already MD5ed in the base. $tabela="agenda_user_fundacao"; //Agenda users table $query="SELECT * FROM ".$tabela." WHERE usuario='".$usuario."' AND senha='".$senha."'"; $consulta=mysql_query($query); $resultado=mysql_num_rows($consulta); if($resultado==true) //If there are results, creates session { $_SESSION["usuario"]=$usuario; $_SESSION["ok"]=true; echo "<script>location.href=('')</script>"; //Redirects to index.php } else //Everytime I run on Chrome and FireOrangeDog, this is what it shows: { echo "<script>alert('Usuário e/ou senha incorreto(s).')</script>"; //Invalid user n' pass. echo "<script>history.go(-1)</script>"; } Can someone help, or this is the end? (... my only friend...) TY, Vinicius. Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/ Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 try putting the error_reporting(0); and then stop the redirecting for a while and echo the $usuario $senha and the $query in the else condition.. Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061114 Share on other sites More sharing options...
ignace Posted May 20, 2010 Share Posted May 20, 2010 if ($resultado == true) is wrong it should be: if (1 === $resultado) { //login OK } else if (0 === $resultado) { //no records found } else { //ambiguous (2 or more records found) } Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061118 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 I tested this, and that's what is happening: When I use a correct user and a incorrect password, this is what it shows: " Usuario: vinicius.costa Senha: e10adc3949ba59abbe56e057f20f883e Query: SELECT * FROM agenda_user_fundacao WHERE usuario='vinicius.costa' AND senha='e10adc3949ba59abbe56e057f20f883e' " Then when I use the right user and the right pass, the user 'disappears': " Usuario: Senha: d41d8cd98f00b204e9800998ecf8427e Query: SELECT * FROM agenda_user_fundacao WHERE usuario='' AND senha='d41d8cd98f00b204e9800998ecf8427e' " I really don't get it O_O Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061122 Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 show me the login form which you are using i mean paste the code Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061124 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 I tryed the if($resultado===1) etc... and I checked the database... Everything is ok. About the login form, it is this way: <body> <div align="center"><img src="img/fundanfip.png" height="100"/></div> <form method="post" action="autentica.php"> <table> <tr id="login"> <td>Usuário:</td> <td> <input name="usuario" type="text" size="30" maxlength="30" /> </td> </tr> <tr id="login"> <td>Senha: </td> <td> <input name="senha" type="password" size="30" maxlength="30" /> </td> </tr> <tr id="login"> <td colspan="2"> <div align="center"> <input type="submit" value="Entrar" /> </div> </td> </tr> </table> </form> </body> Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061128 Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 nothing looks to be wrong.. does ur browser allows cookies.. try the same in some other machine and see what result u are getting.. Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061137 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 Oh, s**t! The cookies! Let me try... Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061141 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 Awwwh. The funniest thing now is that if I go to 'login.php', and fill in with my data, it will go to the else condition in 'autentica.php'. BUT After this, if I go directly to the 'index.php' page, it appears normally. As if I was logged in, and even echoes my name in the page. I'll create a login to you guys, so you can see what I'm talking about. Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061151 Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 so is it going to the index page then?? u can do one thing just go to this site and show me what is wrong http://showmewhatswrong.com/submit/c6nefaVfP Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061155 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 Ok, check it out... Try going to the Web Agenda: http://fundanfipagendatemp.ueuo.com/ It will take you to 'index.php', verify that you are NOT logged in, and redirect you to 'login.php'... The data you must type is: Usuário: test Senha (pass): 123 You will see my debugging notes, and you should also see that the '$usuario' is empty. Then now try to type in the url again http://fundanfipagendatemp.ueuo.com/. It will login in the system, like it had passed through the 'if' and the 'else' condition. I also don't know why in Firefox and Google Chrome, when you click in 'Sair', that is the logout function, it lasts forever in that page. Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061160 Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 it is quite funny though is that the entire code what u are showing... Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061163 Share on other sites More sharing options...
VinnyCP Posted May 20, 2010 Author Share Posted May 20, 2010 Ok, I'll try to talk to the other ITS guys, see if there's any Proxy or Cookie disabled in other browsers, because I tried in another 2 computers, and they all had the same result. IE works, FireOrangeDog doesn't, GChrome neither. Maybe I should try in Opera and Safari, too... G_G Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061167 Share on other sites More sharing options...
Deoctor Posted May 20, 2010 Share Posted May 20, 2010 i dont think it is a problem with the browser.. either it could be ur server issue.. or else could be in the code.. so if u can show me the entire code.. i think i can help u out Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1061178 Share on other sites More sharing options...
VinnyCP Posted May 24, 2010 Author Share Posted May 24, 2010 Hmmmm... Can servers influence this way in a php code? Like, depending on the browser you cannot run it properly? 'Cause if they do, that would be it. I installed EasyPHP in my PC, but it didn't open the http://localhost/ folder, so I got one free server like 'freewebhostingarea', just to test if it's okay. But if the problem happens in the server, when I finish this job, I'll host it in the enterprise server... Quote Link to comment https://forums.phpfreaks.com/topic/202380-trouble-at-work-with-a-login-function-please-help-me/#findComment-1062631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.