<form action="index.php" method="post"><input type="text" name="login" /><br />
<input type="text" name="pass" /><input type="submit" value="send" /></form>
<?php
$conn=mysql_connect("localhost", "root", "krasnal");
mysql_select_db("pass");
$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'])
{
$_SESSION['logged']=$_POST['login'];
echo 'logged';
}
else
{
echo 'Pass or login wrong!!!';
}
}
mysql_close($conn);
?>
please help
[php][mysql]Problem with a session script
Started by 222333, Dec 30 2007 01:00 AM
1 reply to this topic
#1
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".
|
|
|
#2
Posted 30 December 2007 - 11:07 AM
$_POST['pass']==$choose['cpass']
$choose is the query, not the result. $wynik is your result. Even so
$_POST['pass']==$wynik['cpass']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.


Sign In
Create Account

Back to top









