Error Login

This is guide mostly for website tools and code, for example CMS or registration scripts.
There can also be tools.

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Error Login

Postby fede-Raider on Mon Dec 14, 2009 3:02 pm

when I try to login on my site I get error "login failed".

This is the login.php:

  1. <link href="../templates/default/basic.css" rel="stylesheet" type="text/css" />
  2. <form id="form1" name="form1" method="post" action="<?php $PHP_SELF; ?>">
  3.   <p align="center" class="tdglobal"><span class="b01"><?php echo $config['site']['title']; ?> UserCP</span></p>
  4.   <table width="200" border="0" align="center" class="liteoption">
  5.     <tr>
  6.       <td width="97" class="right"><div align="left">Username:</div></td>
  7.       <td width="93" class="right"><input name="user" type="text" class="liteoption" id="user" size="15" maxlength="15" /></td>
  8.     </tr>
  9.     <tr>
  10.       <td class="right"><div align="left">Password:</div></td>
  11.       <td class="right"><input name="pass" type="text" class="liteoption" id="pass" size="15" maxlength="15" /></td>
  12.     </tr>
  13.   </table>
  14.   <p align="center" class="tdglobal"><span class="right">
  15.     <input name="submit" type="submit" class="liteoption" id="submit" value="Log In" size="15" maxlength="15" />
  16.   </span></p>
  17. </form>
  18. <p align="center" class="tdglobal">
  19.   <?php
  20. if(isset($_POST['submit'])) {
  21. $U = $_POST['user'];
  22. $P = md5($_POST['pass']);
  23.  
  24. mysql_connect($cms['db']['host'], $cms['db']['user'], $cms['db']['pass']);
  25. mysql_select_db($cms['db']['name']);
  26.  
  27. $result1 = "SELECT * FROM `accounts` WHERE username='$U' and password='$P' and accesslevel = '100'";
  28. $query = mysql_query($result1);
  29.  
  30.  
  31. $count = mysql_num_rows($query);
  32.  
  33.  
  34. if($count == 1){
  35.  
  36. session_register("User_Name");
  37. session_register("User_Pass");
  38. $_SESSION['account'] = $_POST['user'];
  39. echo('Logged in.... Click <a href=?op=user><strong>here</strong></a>');
  40. }
  41. else {
  42. echo "<strong>Login Failed!</strong>";
  43. }
  44. }
  45. ?>
  46.   <br />
  47. </p>
  48.  
Rose Online Italy: http://roseonlineitaly.tk/
fede-Raider
Pomic
Pomic
 
Posts: 148
Joined: Wed May 20, 2009 7:16 pm

Re: Error Login

Postby lmame on Mon Dec 14, 2009 3:36 pm

You access level is different from 100 perhaps?

Add some echo to see where it fails.

As a side note, your login page is screaming for hacks and mysql injection...
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: Error Login

Postby fede-Raider on Mon Dec 14, 2009 3:49 pm

Can you explain what should I do?
Rose Online Italy: http://roseonlineitaly.tk/
fede-Raider
Pomic
Pomic
 
Posts: 148
Joined: Wed May 20, 2009 7:16 pm

Re: Error Login

Postby lmame on Mon Dec 14, 2009 6:50 pm

  1. echo("Hey, I'm here");
  2.  
  3. echo("my value is ".$P);


Stuff like that...
As for protection, look for mysql_real_escape_string.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: Error Login

Postby fede-Raider on Mon Dec 14, 2009 7:39 pm

sorry but I did not understand what I do (I know little English)
Rose Online Italy: http://roseonlineitaly.tk/
fede-Raider
Pomic
Pomic
 
Posts: 148
Joined: Wed May 20, 2009 7:16 pm

Re: Error Login

Postby lmame on Mon Dec 14, 2009 8:09 pm

You put some echo command at some places to see variables values.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: Error Login

Postby PurpleYouko on Mon Dec 14, 2009 9:28 pm

isn't it fun debugging php? :lol:

problem is you have to be sure where these variables are going to get echo'd
Sometimes they appear in some very strange places if you have any kind of complex layout.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: Error Login

Postby lmame on Mon Dec 14, 2009 9:43 pm

Yep that's why it's better to "surround" data with some markups so you can find it easily in html output ;)
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City


Return to PHP / Web Guides, Scripts and tools.

Who is online

Users browsing this forum: No registered users and 5 guests