Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Having some problems...

Codes here !

Moderators: macek, egami, gesf

Having some problems...

Postby naathyn » Tue Aug 21, 2012 2:00 am

Hi everyone, I am new to the forum... and very new to PHP and MySQL. I have basically had my head deep in these two areas of computing for the last several weeks as I am putting together a mail server as an off project of mine. I have configured postfix, amavis, clamav courier and squirrelmail to put on an apache server with Mysql and PHP (ofcourse).

Cutting to the chase here, I have put together a registration form, and all is going well... except for the password retrieval. You see, when I configured the database to begin with, there was no login script so I was manualy adding user's (beta testers) email accounts in SQL. This is the code I put into SQL:
Code: Select all
INSERT INTO users (local,remote,maildir,pass) VALUES ('localmail','remotemail','maildirectory/',encrypt('password') );

The very last snippet is what is making things difficult... the "encrypt('password')" Because in my registration form the code is:
Code: Select all
if (!get_magic_quotes_gpc()) {
       $_POST['pass'] = crypt($_POST['pass']);
    $register = "INSERT INTO users (local, remote, maildir, pass)
VALUES ('".$_POST['username']."@localhost', '".$_POST['email']."', '".$_POST['username']."/', '".$_POST['pass']."')";

Here is what I get when I register and attempt to login with password "abcd1234":
Code: Select all
Aug 21 04:31:39 localhost authdaemond: supplied password 'abcd1234' does not match encrypted password '$6$rcAusKM7$45RN/pcz1d7TRAY4jKeGq3JSk2Xzf0ARLWFO.TGdgTQGJ.lmSSij7Xg7OMlNHlJbFRYYZ9.P0Mv4QZwBDp3ph.'
Aug 21 04:31:39 localhost authdaemond: authmysql: REJECT - try next module

Even when I copy and paste that password and try to login, it repeats the exact same thing saying it doesn't match.

Keep in mind, I used to manually add passwords to SQL by "encrypt('password')" and was working fine.

What I thought was happening was the password was encrypted before it was even put into the database, therefore the password that was entered was not being retreived. So what I did was took the 'crypt' out of "crypt($_POST['pass'])" Re-registered and logged in with the same password, and here is what I got:
Code: Select all
Aug 21 04:39:43 localhost authdaemond: supplied password 'abcd1234' does not match encrypted password 'abcd1234'
Aug 21 04:39:43 localhost authdaemond: authmysql: REJECT - try next module
Aug 21 04:39:43 localhost authdaemond: FAIL, all modules rejected

So my final conclusion... is that I need to apply the "encrypt('password')" in my PHP script. But I am having trouble. I want to enter it here:
Code: Select all
$register = "INSERT INTO users (x, x, x, pass)
VALUES (x, x, x, '".$_POST['pass']."')";

I thought I would need to write is as (....'"x"', "encrypt('".$_POST['crypt']."')")"; Ughh that looks horendous lol.

I'm getting nailed on that one. Afterall, that might not even solve the problem. I was just going to try encrypting inside php AS it was being added to the database. By the way, the "$_POST['pass']" (if you haven't already figured out) is the user's password as submitted in the form.

Something to add, I have phpma and each account is being successfully added as well as the verification email being sent to the user's mailbox upon registration. When I entered the unencrypted password as "abcd1234" it was sitting in the table just as that. All of my account I had made previously by manually inserting the information into SQL could log in fine, and their passwords were showing as encrypted... I just dont know what the problem is.

Anyway, nice to be here... any help or suggestions/further reading would be greatly appreciated!

New php-forum User
New php-forum User
Posts: 1
Joined: Tue Aug 21, 2012 1:10 am

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.