What version of PHP are you using? If it's 4.2 or later, then Dreamweaver's code will fail on a default PHP configuration, because it's using deprecated session-handling functions [man]session_register[/man] etc.. You can reconfigure PHP by turning register_globals ON in php.ini (and if that's what your host is using you might as well do so); but it was turned off by default for security reasons.
Ironically, it's using session_register() and $SESSION - something that the PHP manual explicitly warns against using together (the $SESSION array is intended to replace use of session_register()), and not only that, but storing some of those session variables in the $GLOBAL array (which is daft, because $_SESSION is global anyway).
I'd estimate that Dreamweaver is coding on the assumption that you're using PHP 4.1 (it's using constructs that were not present in 4.0, and as noted it's assuming that register_globals is turned on, though it's not in 4.2). Possibly there's a switch in Dreamweaver that will change that behaviour (I don't use it; and judging from that code I'm kinda glad I don't).
It may be possible to salvage the code with altering your configuration (while still having it run on your host). Ditch the session_register() calls,
using $_SESSION['whatever'] in places where a session variable named $whatever
is being used, and they don't need to be declared global. For example, instead
of
//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");
You would have
//Assign two session variables.
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
I've just noticed something else.
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
"&& false"? As I said, I don't know why Dreamweaver writes what it does (so I don't know what you'd tickle to change this), but if(anything && false) is guaranteed to fail. So $MM_redirectLoginSuccess never gets set to $_SESSION['PrevUrl'], and just keeps whatever value it already had.
Oh, and one more thing. echoing the value of mysql_error() when there is an error is valuable when development, but it should never be used in a real live site as all it does is provide attackers with information that helps them debug their attacks (the same goes for PHP's own errors: display_errors=off in php.ini for live sites, please!)
And don't mind me much; I'm the grumpy one.