Ask a Question related to Macromedia Dreamweaver, Design and Development.
-
SpeedRacer21 webforumsuser@macromedia.com #1
User Login to Redirect using PHP
I've read many posts about redirecting a user by specifying the directin url in the database, but have had very little luck. I'm using Dreamweaver's user authentication login extensions, and telling the "if successful login, go to page:" to point to the redirect field in the database by clicking browse..data sources...redirect(recordset value). This seems to work only for the first user in the database, ie. any other user is verified, but still directed to the first users redirect page. I have included the code to view(nothing fancy). Please be detailed in explaination, being I'm not that handy with coding and general "do this and do that" talk.
Thank you to anyone who might be able to help me.
<?php require_once('Connections/PasswordDB.php'); ?>
<?php
mysql_select_db($database_PasswordDB, $PasswordDB);
$query_Recordset1 = "SELECT * FROM Trial";
$Recordset1 = mysql_query($query_Recordset1, $PasswordDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
// *** Validate request to log in to this site.
session_start();
$loginFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($accesscheck)) {$GLOBALS['PrevUrl'] = $accesscheck;
session_register('PrevUrl');}
if (isset($HTTP_POST_VARS['textfield'])) {$loginUsername=$HTTP_POST_VARS['textfield'];
$password=$HTTP_POST_VARS['textfield2'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = $row_Recordset1['redirect'];
$MM_redirectLoginFailed = "/index.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_PasswordDB, $PasswordDB);
$LoginRS__query=sprintf("SELECT username, password FROM Trial 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, $PasswordDB) 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($HTTP_SESSION_VARS['PrevUrl']) && false) { $MM_redirectLoginSuccess = $HTTP_SESSION_VARS['PrevUrl'];
} header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="585" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="585" height="178" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="261" valign="top"><form ACTION="<?php echo $loginFormAction; ?>" name="form1" method="POST">
<p>
<input type="text" name="textfield">
</p>
<p>
<input type="text" name="textfield2">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
SpeedRacer21 webforumsuser@macromedia.com Guest
-
Login Redirect
Hi, all I have this login script that calls on itself to authenticate the username and the password. It redisplays the login page if there is an... -
redirect to guest if first redirect is doesnt work for a user
Hi all, I was wondering if anyone could help me solve a problem Once a user hits a certain webpage ..I try to redirect them to another using... -
Cookie not set after login and redirect
Hello I have setup a forms authentication login page and use custom principal and identity. When authenticate everything goes well. But when I set... -
How to set redirect default on login?
Sorry, FormsAuthentication is hard set to "default.aspx" when doing the RedirectFromLoginPage and/or GetRedirectUrl Just execute SetAuthCookie... -
Login User and Redirect to a specific page - help required
I'm using ASP/Access 2000. This is what I would like to do. A site has a limited number of users - User Bert logs in and assuming gets thru... -
JREYES-MMTS #2
Re: User Login to Redirect using PHP
Hi SoeedRacer21,
Try doing this:
Go back to the original code inserted by the login server behavior. You
don't need to create another recordset to get the page that you should
redirect to. That information can be pulled from the recordset that checks
the username/password. Add 'redirect' to the list of fields being retrieved
"username,password,redirect".
add this code below "$GLOBALS['MM_UserGroup'] = $loginStrGroup;"
$MM_redirectLoginSuccess = mysql_result($LoginRS,0,'redirect');
Hope this helps
Jaybee Reyes
Macromedia Technical Support
JREYES-MMTS Guest
-
SpeedRacer21 webforumsuser@macromedia.com #3
Re: User Login to Redirect using PHP
Thank you so much for your help. This worked perfectly! Do I need to add a behavior to the individual user pages to keep unautherized people from viewing this page by directly typing it in to the title bar?
I am very grateful to you. You don't know how much headache this has caused me. Thank you.
SpeedRacer21 webforumsuser@macromedia.com Guest
-
JREYES-MMTS #4
Re: User Login to Redirect using PHP
Hi SpeedRacer21,
Glad that worked for you. As for the page restrictions, I would recommend
adding that. But from what you are describing, this is not something that
can be handled by the restrict access behavior. The only way I can see this
working with the behavior is if you use user level permissions. You will
have to create a user level for each user. A bit tedious but it should work.
Regards,
Jaybee
JREYES-MMTS Guest



Reply With Quote

