Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-30-2007, 04:00 AM
222333 222333 is offline
Newbie
 
Join Date: Dec 2007
Posts: 1
Rep Power: 0
222333 is on a distinguished road
Arrow [php][mysql]Problem with a session script

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".

PHP Code:
<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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-30-2007, 02:07 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

PHP Code:
$_POST['pass']==$choose['cpass'
$choose is the query, not the result. $wynik is your result. Even so
PHP Code:
$_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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hacking Perl Script falco85 Perl 7 10-08-2008 05:11 PM
Make a script vulnerable to SQL injection? shibbythestoner PHP Forum 7 12-15-2007 09:56 PM
JavaScript:Tutorial, Using an External Script TcM Javascript 7 09-11-2007 08:39 AM
Need Help With a Script tfusion PHP Forum 5 04-14-2007 08:35 PM


All times are GMT -5. The time now is 07:03 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads