Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Topics

Recent Status Updates

View All Updates

- - - - -

[php][mysql]Problem with a session script

mysql session

  • Please log in to reply
1 reply to this topic

#1 222333


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 30 December 2007 - 01:00 AM

My script works on sessions. It connects to MySQL Database and chooses a password. Something is wrong, because it doesn't work - it always shows "Pass or login wrong".

<form action="index.php" method="post"><input type="text" name="login" /><br />
<input type="text" name="pass" /><input type="submit" value="send" /></form>

$conn=mysql_connect("localhost", "root", "krasnal");
$choose="SELECT `cpass` FROM `pass`";
$r = mysql_query($choose);
$wynik = mysql_fetch_array($r);

if(!empty($_POST['login']) && !empty($_POST['pass']))
if($_POST['login']=='login' && $_POST['pass']==$choose['cpass'])
echo 'logged';
echo 'Pass or login wrong!!!';




please help
  • 0

#2 John


    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 30 December 2007 - 11:07 AM


$choose is the query, not the result. $wynik is your result. Even so

will still return false because $wynik['cpass'] is an array of strings, not a single string, which you are checking for. You can get it to work using a loop or one of the array functions, but in general this is a poor login script.
  • 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download