This topic is locked

Conditonal URL link

8/12/2011 9:46:38 AM
PHPRunner General questions
D
dougperk author

I want to place a link field on my form which sends the user to a specific URL. However the destination URL needs to be dependent upon the userid of the user currently signed in. Example: (note in URL that folder of 'Calendar' name is changing
USERID URL Destination
MaryP http://dwmed.com/DWMedCalendar4/calmonthly_list.php

DougL http://dwmed.com/DWMedCalendar5/calmonthly_list.php

ChrisH http://dwmed.com/DWMedCalendar6/calmonthly_list.php
How would I go about doing this.
Doug Perkinson

C
cgphp 8/12/2011

In the visual editor swith to the HTML code and place a reference (var template) to your link like the following:

{$link_form}



Then in the "Before display" event of your page assign a link value to the var template:

switch($_SESSION['UserID'])

{

case "MaryP":

$link = "<a href='http://dwmed.com/DWMedCalendar4/calmonthly_list.php'>Click here</a>";

break;

case "DougL":

$link = "<a href='http://dwmed.com/DWMedCalendar5/calmonthly_list.php'>Click here</a>";

break;

case "ChrisH":

$link = "<a href='http://dwmed.com/DWMedCalendar6/calmonthly_list.php'>Click here</a>";

break;

}
$xt->assign("link_form",$link);