Forums

This topic is locked

If Login Fails, Go to PROBLEM - HELP ASAP PLEASE?!

Posted 19 Apr 2007 18:15:11
1
has voted
19 Apr 2007 18:15:11 Autumn W posted:
Hi folks,

Hopefully there's someone smarter than me on this forum because my DWMX is possessed and I need serious help. LOL

I initially created a login form for my members, connected it to my members connection script, and chose my "help.php" page for the redirect if the login failed.

The login CONTINUALLY failed.

So I started messing with the script, trying to figure out why. But here's the weird thing... I can create an ENTIRELY new page, new form, use the Login User behavior and set the redirect page to a new page that I created called "login_failed" and NO MATTER HOW MANY TIMES I UPLOAD THE NEW PAGE, the connection scripts, etc. it STILL takes me back to "help.php" - the ORIGINAL fail page.

WTF?????

I've even tried renaming the new login page with a completely random name (rather than login2.php, login3.php etc, as I has been doing).

DWMX is somehow saving the information that I originally put in for that first login script SOMEWHERE and I have no idea where.

Any ideas?

PLEASE? LOL

Also: I'm wondering how to get the login script to check the database to make sure that active='y'. It doesn't seem to use a recordset, just the members connection script, so how am I supposed to tell it to do that? I looked at the "access level" function, but it doesn't allow me to put a specific setting for the "active" variable in there.

Thanks,

Autumn

Edited by - oregonbigfoot on 22 Apr 2007 03:33:49

Replies

Replied 19 Apr 2007 18:18:53
19 Apr 2007 18:18:53 Autumn W replied:
P.S. I still haven't figured out WHY my user authentication page isn't logging me in when I have a valid username/password combo, but I suspect that whatever's causing the above problem might be causing that as well. FWIW, when I programmed all of this in Ultradev 4 it worked great. I'm hating this new dreamweaver.....

Edited by - oregonbigfoot on 19 Apr 2007 18:19:13
Replied 20 Apr 2007 21:04:01
20 Apr 2007 21:04:01 Javier Castro replied:
Post what you have(code)
Replied 22 Apr 2007 03:33:16
22 Apr 2007 03:33:16 Autumn W replied:
Sorry for the delay in replying.

I'll post my code below. This is SO messed up! On my local machine (laptop), the login works FINE WHEN I ACCESS IT IN THE BROWSER AFTER UPLOADING IT. On every other machine, including the one upstairs, it does not work, which tells me that it's pulling something from my local machine to function, but I can't figure out what.

None of my members can get in. Any help would be appreciated!

Here's the code from the login page:

<?php require_once('Connections/connect_members.php'); ?>
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');
}

if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "www.oregonbigfoot.com/members/index.php";
$MM_redirectLoginFailed = "www.oregonbigfoot.com/help.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connect_members, $connect_members);

$LoginRS__query=sprintf("SELECT username, password FROM memberinfo WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));

$LoginRS = mysql_query($LoginRS__query, $connect_members) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$GLOBALS['MM_Username'] = $loginUsername;
$GLOBALS['MM_UserGroup'] = $loginStrGroup;

//register the session variables
session_register("MM_Username";
session_register("MM_UserGroup";

if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>

MORE INFO (hope this will help):

PHP version 4.4.4
MySQL version 4.1.21-standard


Edited by - oregonbigfoot on 22 Apr 2007 03:35:00

Edited by - oregonbigfoot on 22 Apr 2007 03:36:05
Replied 22 Apr 2007 14:32:06
22 Apr 2007 14:32:06 Kenneth Halley replied:
I had some issues with the default login scripts in DW- though I usually end up modifying them to get extra parameters into the Sessions and also to have MD5 encrypted passwords so think my tinkering can break stuff at times!
DW sometimes gets upset as the code is no longer the pure version they provide- but again you can get round this to an extent by putting the login script into an included file and pointing the login forms at it.

However back to your issue. Your script looks fairly default to a quick scan, but thats not to say there would be no issues- try the following:
On your server when you login check the session is being created and populated- sessions are usually stored in the /tmp directory. If you empty it and then login you can see your session file there and open it in a text editor to see the contents- your registered variables should all be there. . If you don't have access to the files in /tmp you will need to add some debug code to echo the contents of the session to the browser at various stages of the processing of the file. Also look in your error logs to see if an error is being generated at the time you logged in.

You just want to echo out each parameter of the array, and comment out the redirect line so it doesn't.
You just want the script to stop dead while you debug.
ie after the session register do an echo on those same parameters.
<?php echo $_SESSION['MM_Username']; ?> etc
and put
// in front of the redirect lines


If it seems OK start putting code back - your redirects are to absolute URLs- is there a reason for this- you are logging onto the same server? If not then your sessions are not going to work.


Next- a problem I had a wee while back that i can't really explain. I develop locally on a windows server but most of my hosting is on Linux. So it might be an issue with this. But in one case I found that the session_register function just did not work on the windows machine- it would populate the session but none of the paremeters had anything in them.
Changing those lines to
$_SESSION['MM_Username']= $GLOBALS['MM_Username'] ;
$_SESSION['MM_UserGroup']= $GLOBALS['MM_UserGroup'];

Sorted it on the windows machine- Has never been a problem on Linux.

Maybe this will help?


-----------------------------------
www.halleynet.co.uk
Replied 22 Apr 2007 18:40:37
22 Apr 2007 18:40:37 Autumn W replied:
Thank you SO MUCH for the response. You know what's weird? I had tried creating a login script OUTSIDE of my template, uploaded it, and it worked across the board. So then I did an include, and just ncluded the login page in the body of my template... worked like a charm. I have NO IDEA why on earth the template would be screwing things up...

I have the URLs as absolute because I was having problems with them set as relative. Again, dunno why. LOL

Thanks for the feedback. I guess the work around is good enough. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Replied 27 Apr 2007 23:14:41
27 Apr 2007 23:14:41 Autumn W replied:
Well... maybe not. LOL

I just found out that EVERY person who registers is getting access, even if the field in the database ("active" is set to 'N' instead of 'Y'.

On my old UD4, I could set it up so that the access restriction would check the database to make sure that the user is active='Y'. There doesn't appear to be a way to do this in the new one.

Any suggestions?

I'm also confused about the fuction of the "access level" in the login user behavior. That doesn't apparently seek out the information from the database.

Argh.

Thanks,

Autumn

Reply to this topic