gina
|
| Posted: 10/28/2002, 8:00 AM |
|
I would like to use the redirect tip found here:
http://www.gotocode.com/art.asp?art_id=55&
Only thing is, it tells me to insert the code in the open event of my redirect page. In ccs, I can't find the open event, like I would in CC2. Where should I insert the redirect code in Code Charge Studio?
Thanks
|
|
|
 |
xbill
|
| Posted: 10/28/2002, 9:01 AM |
|
The custom event handling was completely
reworked in CCS over CC.
The CCS way has much more flexibility- but it is
a little harder to get use to.
First open the page. Select the "Events" tab
on the Properties box in the workspace. It is
the third tab. (The default is the middle tab
"Data").
Depending on which object you have selected-
the available events will show up. To get
the page events- click on some blank space
outside any object. The title will say something
like "Page: yourpagename".
On the properties box- you have "After Initialize" ,
"Before Show" etc. You can select an event
and then right click your mouse to add custom code
or an action to the event. If you add custom code-
the editor will appear and you can enter code
in the target language. Make sure to keep the CCS tags
intact in the editor.
If click on a form or a grid- the events available
change according to the object selected.
So - to add a custom event on the page- you can
use the "After Initialize" or the "Before show"
on the page with some custom code.
-bill
|
|
|
 |
gina
|
| Posted: 10/28/2002, 10:38 AM |
|
Bill,
thank you for the help on CCS, that made everything more clear. I inserted the code in the before show event. When I try to login, I don't get redirected to the declared page...instead, I just go to the redirect page with a header and footer. I'm not getting any syntax errors, but I don't get redirected. Here's the code I'm using on the redirect_events page. Any suggestions?
function Page_BeforeShow() { //Page_BeforeShow @1-66DC429C
//Custom Code @4-2A29BDB7
if (CCGetSession("GroupID") == 1)
header("Location: trialmenu.php");
if (CCGetSession("GroupID") == 2)
header("Location: membermenu.php");
if (CCGetSession("GroupID") == 3)
header("Location: adminmenu.php");
// -------------------------
//End Custom Code
|
|
|
 |
RonB
|
| Posted: 10/28/2002, 2:32 PM |
|
if (CCGetSession("GroupID") == 1)
header("Location: trialmenu.php");
if (CCGetSession("GroupID") == 2)
header("Location: membermenu.php");
if (CCGetSession("GroupID") == 3)
header("Location: adminmenu.php");
should be
if(CCGetSession("GroupID") == "")
{
header("Location: yourloginpage.php");
}
elseif (CCGetSession("GroupID") == 1)
{
header("Location: trialmenu.php");
}
elseif(CCGetSession("GroupID") == 2)
{
header("Location: adminmenu.php");
}
header("Location: membermenu.php");
}
elseif (CCGetSession("GroupID") == 3)
{
The problem with your code is it checkes for a session variable that presumably is set by the login procedure. You didn't specify what to do if non of the criteria you set in your if statement returns true.
With the above code it first checkes if the session variable has a value at all, if not it redirects to the login page. If it has a value the rest of the if statement is run.
Hope this helps.
Ron
|
|
|
 |
gina
|
| Posted: 10/28/2002, 3:28 PM |
|
Ron,
thank you for your help. I think it's close to being fixed, but not quite working yet. When I tried your code (I modified it a little because I was getting parse errors with the orig), this is the code I used:
if(CCGetSession("GroupID") == "")
{
header("Location: login.php");
}
elseif (CCGetSession("GroupID") == 1)
{
header("Location: trialmenu.php");
}
elseif(CCGetSession("GroupID") == 2)
{
header("Location: membermenu.php");
}
elseif (CCGetSession("GroupID") == 3)
{
header("Location: adminmenu.php");
}
Now, when I log in, it logs me in, but just reloads the login page (rather than redirecting). I know I'm logged in, because I'm able to get to restricted pages that would not be possible to get into when I'm not logged in, but it still doesn't redirect me to the pages requested in the code. Any other suggestions? Thanks in advance for your help!
|
|
|
 |
RonB
|
| Posted: 10/30/2002, 4:11 AM |
|
Hmm, Check if the groupid you check in the if statment corresponds with the groupid needed for that particular page. In the IE adress bar you'll get a message like: Illegalgroup if it doesn't.
Going back to the login page usualy means that the value in the sessionvariable doen't match the value requested by the protected page.
To check this you could place a label on your login page in wich you display the groupid passed as session variable. In custom event for that label you could place the following code:
global $gridname;
$gridname->labelname->setvalue(CCGetSession("GroupID","");
Give it a try
|
|
|
 |
gina
|
| Posted: 10/30/2002, 9:28 AM |
|
I tried checking the group id... it did not match the value. When I reset the value of group id to match my code (GroupID), it worked! Here's the code I used for the before show event of the redirect page...hope this can help someone else:
if(CCGetSession("GroupID") == "")
{
header("Location: login.php");
}
elseif (CCGetSession("GroupID") == 1)
{
header("Location: trialmenu.php");
}
elseif(CCGetSession("GroupID") == 2)
{
header("Location: membermenu.php");
}
elseif (CCGetSession("GroupID") == 3)
{
header("Location: adminmenu.php");
}
Now, the three user groups (admin, member and trial) are directed to the right page, rather than just one default page. Thank you Ron and Bill for your help!
Gina
|
|
|
 |
|