Forums
This topic is locked
User Login and then dynamic redirect
Posted 24 Feb 2005 19:15:01
1
has voted
24 Feb 2005 19:15:01 Antony Ware posted:
Hi I'm using Dreamweaver MX and have downloaded an extension for the PHP User Login Server behaviour, which I may add works perfectly. My challenge now is to send the authenticated user to a specific page (or his / her own client area). With my limited knowledge of PHP I've not been able to get it right. I'm able to point the Success Page to a certain page which has a little PHP code snippet in the Head tags allowing me to direct the user to a specific location, but I need that redirection to be dynamic, so for example user A logs in he gets sent to User A's unique area. Please help someone...
Replies
Replied 24 Feb 2005 20:03:07
24 Feb 2005 20:03:07 Chris Charlton replied:
Doing a <i>switch case</i> statement, or even at least an <i>if...else</i> statement should suffice.
I'm not sure what 3rd-party PHP [i[User Login Suite</i> you are using, so it's hard to help with. Can you post what extension, version, and where you got it from please. Also,l if you can post a code snippet of the <i>Login Server-Behavior[/i], so we can see what SESSION variables are declared when logging in. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
I'm not sure what 3rd-party PHP [i[User Login Suite</i> you are using, so it's hard to help with. Can you post what extension, version, and where you got it from please. Also,l if you can post a code snippet of the <i>Login Server-Behavior[/i], so we can see what SESSION variables are declared when logging in. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 24 Feb 2005 20:13:31
24 Feb 2005 20:13:31 Antony Ware replied:
Hi Chris
Thanks for responding. The third-party PHP User Login Suite is Mini PHP Login.
I'm not too sure which part of the code snippet constitutes the Login Server-Behaviour so I'll just include all the PHP code that appears before the HTML tag. Sorry I hope this helps.
Antony
Thanks for responding. The third-party PHP User Login Suite is Mini PHP Login.
I'm not too sure which part of the code snippet constitutes the Login Server-Behaviour so I'll just include all the PHP code that appears before the HTML tag. Sorry I hope this helps.
Antony
Replied 24 Feb 2005 20:32:58
24 Feb 2005 20:32:58 Antony Ware replied:
So Sorry Chris
Here is that code I promised:
<pre id=code><font face=courier size=2 id=code>
<?php
include ("Connections/FlowTest.php"
function quitar($mensaje)
{
$mensaje = str_replace("<","<",$mensaje);
$mensaje = str_replace(">",">",$mensaje);
$mensaje = str_replace("\'","'",$mensaje);
$mensaje = str_replace('\"',""",$mensaje);
$mensaje = str_replace("\\\\","\",$mensaje);
return $mensaje;
}
if(isset($HTTP_POST_VARS["tcnUsername"]) && isset($HTTP_POST_VARS["tcnPassword"]))
{
$userN = quitar($HTTP_POST_VARS["tcnUsername"]);
$passN = quitar($HTTP_POST_VARS["tcnPassword"]);
mysql_select_db($database_FlowTest, $FlowTest);
$result = mysql_query("SELECT floPassWord FROM flowPass WHERE floPassName ='$userN'"
if($row = mysql_fetch_array($result))
{
if($row["floPassWord"] == $passN)
{
//90 days for the cookie
setcookie("tcn_username",$userN,time()+7776000);
setcookie("tcn_password",$passN,time()+7776000);
header("Location:loginSuccess.php"
}
else
{
header("Location:loginFailed.php"
}
}
else
{
header("Location:register.php"
}
mysql_free_result($result);
}
mysql_close();
?>
<?php require_once('Connections/FlowTest.php'); ?>
<?php
mysql_select_db($database_FlowTest, $FlowTest);
$query_rsLogin = "SELECT * FROM flowPass";
$rsLogin = mysql_query($query_rsLogin, $FlowTest) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);
?></font id=code></pre id=code>
Here is that code I promised:
<pre id=code><font face=courier size=2 id=code>
<?php
include ("Connections/FlowTest.php"
function quitar($mensaje)
{
$mensaje = str_replace("<","<",$mensaje);
$mensaje = str_replace(">",">",$mensaje);
$mensaje = str_replace("\'","'",$mensaje);
$mensaje = str_replace('\"',""",$mensaje);
$mensaje = str_replace("\\\\","\",$mensaje);
return $mensaje;
}
if(isset($HTTP_POST_VARS["tcnUsername"]) && isset($HTTP_POST_VARS["tcnPassword"]))
{
$userN = quitar($HTTP_POST_VARS["tcnUsername"]);
$passN = quitar($HTTP_POST_VARS["tcnPassword"]);
mysql_select_db($database_FlowTest, $FlowTest);
$result = mysql_query("SELECT floPassWord FROM flowPass WHERE floPassName ='$userN'"
if($row = mysql_fetch_array($result))
{
if($row["floPassWord"] == $passN)
{
//90 days for the cookie
setcookie("tcn_username",$userN,time()+7776000);
setcookie("tcn_password",$passN,time()+7776000);
header("Location:loginSuccess.php"
}
else
{
header("Location:loginFailed.php"
}
}
else
{
header("Location:register.php"
}
mysql_free_result($result);
}
mysql_close();
?>
<?php require_once('Connections/FlowTest.php'); ?>
<?php
mysql_select_db($database_FlowTest, $FlowTest);
$query_rsLogin = "SELECT * FROM flowPass";
$rsLogin = mysql_query($query_rsLogin, $FlowTest) or die(mysql_error());
$row_rsLogin = mysql_fetch_assoc($rsLogin);
$totalRows_rsLogin = mysql_num_rows($rsLogin);
?></font id=code></pre id=code>
Replied 24 Feb 2005 22:58:42
24 Feb 2005 22:58:42 Chris Charlton replied:
Ok, I don't see any SESSION variables implimented in that code, but if there was more to it, I'd like you to provide a link to this <i>Mini PHP Login</i>. But I do see where a COOKIE is handled:
<pre id=code><font face=courier size=2 id=code>//90 days for the cookie
setcookie("tcn_username",$userN,time()+7776000);
setcookie("tcn_password",$passN,time()+7776000);</font id=code></pre id=code>
So, in DW MX, in your <i>Applications</i> panel, you would easy <b>add Cookie, and these are the two names you'll add</b>:
<ul><li>tcn_username</li><li>tcn_password</li></ul>
I'd look around the code it generates to see if <i>any</i> SESSION variables are used. <b>If you want to learn about Cookies & Sessions in PHP</b>, check out:
<ul><li><b>PHP Basics - Part 8: Cookies and Sessions</b> - www.dmxzone.com/go?6656</li><li><b>Working with Session Variables in PHP</b> - www.dmxzone.com/go?5454</li><li><b>User-Customised Content - Building content based on user profiles</b> - www.dmxzone.com/go?6587</li><li><b>Advanced User-Customised Content</b> - www.dmxzone.com/go?6604</li></ul>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
<pre id=code><font face=courier size=2 id=code>//90 days for the cookie
setcookie("tcn_username",$userN,time()+7776000);
setcookie("tcn_password",$passN,time()+7776000);</font id=code></pre id=code>
So, in DW MX, in your <i>Applications</i> panel, you would easy <b>add Cookie, and these are the two names you'll add</b>:
<ul><li>tcn_username</li><li>tcn_password</li></ul>
I'd look around the code it generates to see if <i>any</i> SESSION variables are used. <b>If you want to learn about Cookies & Sessions in PHP</b>, check out:
<ul><li><b>PHP Basics - Part 8: Cookies and Sessions</b> - www.dmxzone.com/go?6656</li><li><b>Working with Session Variables in PHP</b> - www.dmxzone.com/go?5454</li><li><b>User-Customised Content - Building content based on user profiles</b> - www.dmxzone.com/go?6587</li><li><b>Advanced User-Customised Content</b> - www.dmxzone.com/go?6604</li></ul>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 24 Feb 2005 23:04:51
24 Feb 2005 23:04:51 Antony Ware replied:
www.tecnorama.org/document.php?id_doc=48
Sorry Chris my knowledge of Cookies and Sessions isn't that good either. But I've just tried a similar thing in ASP in Dreamweaver, and in the Login User Dynamically Redirect dialogue it gives you the option to redirect to a URL from the database. That is exactly what I want the script to do. Please let it be possible in PHP.
Thanks
Antony
Sorry Chris my knowledge of Cookies and Sessions isn't that good either. But I've just tried a similar thing in ASP in Dreamweaver, and in the Login User Dynamically Redirect dialogue it gives you the option to redirect to a URL from the database. That is exactly what I want the script to do. Please let it be possible in PHP.
Thanks
Antony
Replied 25 Feb 2005 03:57:31
25 Feb 2005 03:57:31 Chris Charlton replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>www.tecnorama.org/document.php?id_doc=48
Sorry Chris my knowledge of Cookies and Sessions isn't that good either. But I've just tried a similar thing in ASP in Dreamweaver, and in the Login User Dynamically Redirect dialogue it gives you the option to redirect to a URL from the database. That is exactly what I want the script to do. Please let it be possible in PHP.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
If you were able to do it in ASP, then it was Dreamweavers' default ASP <i>User Login Suite</i>, and if it's not available from your extension then you will need some custom code or request the feature from the Extension creator.
To do a redirect based on user, in PHP, it would be something like...
<pre id=code><font face=courier size=2 id=code><?php
$userPrivelage = $_SESSION['userGroup'];
if($userPrivelage = "admin"{
header("Location: admin_menu.php"
} else if ($userPrivelage = "user"{
header("Location: main_menu.php"
} else {
header("Location: login.php"
}
?></font id=code></pre id=code>
I hope this help guide you. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Sorry Chris my knowledge of Cookies and Sessions isn't that good either. But I've just tried a similar thing in ASP in Dreamweaver, and in the Login User Dynamically Redirect dialogue it gives you the option to redirect to a URL from the database. That is exactly what I want the script to do. Please let it be possible in PHP.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
If you were able to do it in ASP, then it was Dreamweavers' default ASP <i>User Login Suite</i>, and if it's not available from your extension then you will need some custom code or request the feature from the Extension creator.
To do a redirect based on user, in PHP, it would be something like...
<pre id=code><font face=courier size=2 id=code><?php
$userPrivelage = $_SESSION['userGroup'];
if($userPrivelage = "admin"{
header("Location: admin_menu.php"
} else if ($userPrivelage = "user"{
header("Location: main_menu.php"
} else {
header("Location: login.php"
}
?></font id=code></pre id=code>
I hope this help guide you. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 04 Mar 2005 15:56:13
04 Mar 2005 15:56:13 Matt Bailey replied:
You could have a look at this extension www.dreamweavermxsupport.com/index.php?type=news&newsid=24&block=2 (PHP Login Suite). It may be that it will do what you need.
___________________________________
* Sorry... how do you do that again?... *
___________________________________
* Sorry... how do you do that again?... *
Replied 04 Mar 2005 19:46:14
04 Mar 2005 19:46:14 Chris Charlton replied:
Good link Matt! That PHP Login Suite extension seemed to have a lot of SB's (Server-Behaviors). <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Do you mind adding it to DMXzones' <i>Extensions</i> section, if you can't then reply here on this forum (or contact me). At the minimum it would do good in the <i>Links</i> section.
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Do you mind adding it to DMXzones' <i>Extensions</i> section, if you can't then reply here on this forum (or contact me). At the minimum it would do good in the <i>Links</i> section.
~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>