What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » what is wrong with this php code.....

what is wrong with this php code.....
Author: Message:
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
O.P. what is wrong with this php code.....
i dont actually get any errors
it just doesnt let me login
code:
<?
session_start();
if($_POST['submit'])
{
mysql_connect("localhost","****","****");
mysql_select_db("crimpa_forum");
$user = ($_POST['username']);
$pass = md5($_POST['password']);
$query = mysql_query("SELECT * FROM users WHERE username = '$user' AND password = '$pass' ");
$rows = mysql_num_rows($query);
      if($rows == 1)
      {
      echo 'user logged in successfully';
      $_SESSION['user'] = $user;
      $_SESSION['pword'] = md5($pword);     
      }
      else { echo 'incorrect username or password'; }
}
else
{
?>
<form method="post" action="login.php">
<TABLE>
<TR>
   <TD valign="top">Username:</TD>
   <TD><INPUT NAME='username' TYPE='TEXT' VALUE='' size=30 maxlength="30"></TD>
</TR>
<TR>
   <TD valign="top">Password</TD>
   <TD><INPUT NAME='password' TYPE='password' VALUE='' size=30 maxlength="16">
</TR><br>
   <TD valign="top"></TD>
   <TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>
<?
}
?>
09-19-2004 03:06 PM
Profile PM Find Quote Report
Choli
Elite Member
*****

Avatar
Choli

Posts: 4714
Reputation: 42
42 / Male / Flag
Joined: Jan 2003
RE: what is wrong with this php code.....
quote:
Originally posted by leejeffery
$_SESSION['pword'] = md5($pword); 
I don't kno wmuch PHP, but shouldn't that line be $_SESSION['pword'] = $pass ?
Messenger Plus! en español:
<< http://www.msgpluslive.es/ >>
<< http://foro.msgpluslive.es/ >>
:plus4:
09-19-2004 03:19 PM
Profile PM Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
O.P. RE: what is wrong with this php code.....
yeh ur right :P
still wont login mind ¬_¬
09-19-2004 03:26 PM
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: what is wrong with this php code.....
I suggest you do such debug:

1. echo the query ( "SELECT * FROM users WHERE username = '$user' AND password = '$pass' " ) to see if the query was executed correctly
2. echo $rows
09-19-2004 03:55 PM
Profile PM Web Find Quote Report
bach_m
Veteran Member
*****

Avatar
4837 :P

Posts: 2863
Reputation: 7
37 / Male / –
Joined: Feb 2003
RE: what is wrong with this php code.....
better than echo for an array: print_r
09-19-2004 04:19 PM
Profile E-Mail PM Web Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: what is wrong with this php code.....
bach_m, his $rows is the number of the rows of the result of the query, not the rows themselves :P
09-20-2004 12:48 PM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
O.P. RE: what is wrong with this php code.....
in case you didnt know, i was using this code because i was scripting my own forum but this login code just doesnt want to work and if people cant login then why bother. so i sort of gave up on making it :P
if anyone could get it to work i would continue :P
09-20-2004 03:10 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On