Copy link to clipboard
Copied
I have created a page where the user will enter one of several codes. I wanted to use the login function and validate the code against a table that I have pre-loaded with these codes. The code entered would control which page was displayed to the user.
(I have identified a community of potential clients, and this group is broken down into 10 unique sub-groups. Each person receives a mail that includes one of 10 unique 'codes', which identify the sub-group. When the recipient calls up my website and enters the code (as a user ID), this will determine which of the 10 pages is displayed. If someone randomly enters (or mis-keys) a value into the promo field a default error page (page #11) would display.)
Is this possible using the log-in function. Now that I'm looking at the function, it appears that any successful log-in will be directed to the same page. If I can't use the log-in function, how can I accomplish this. In essence, I am looking for the successful codes to act as an "if . . .then . . .else . . " type of logic. Or, a successful hit on one of records in my table is akin to making a menu selection (that is not available in any other fashion).
Any help on this would be greatly appreciated.
BTW - kudos to David Powers and Charles Nadeau for the great tutorial on Setting up a PHP development environment for Dreamweaver!
Copy link to clipboard
Copied
If you want to redirect to different pages I think you will need to code this by hand. Simply store the appropriate page for each code in the database. Retrieve that when the user logs in and use it to redirect.
The other way to do this, which will allow you to use the standard server behavior, is to redirect everyone to the same page, but populate that page with data stored in the database which varies by code.
Copy link to clipboard
Copied
The Dreamweaver Log In User and Restrict Access to Page server behaviors use $_SESSION['MM_Username'] to store the user's login name. The Log In User server behavior lets you specify only one successful landing page, but you could use $_SESSION['MM_Username'] to redirect the user.
if ($_SESSION['MM_Username'] == 'xyz') {
header('Location: somespecialpage.php');
exit;
}
This needs to go after the Restrict Access to Page server behavior code.
Because you have 11 pages, you could create an array of target pages:
$redirects = array('xyz' => 'somespecialpage.php', 'yxz' => 'another.php');
header ('Location: ' . $redirects[$_SESSION['MM_Username']]);
exit;
Copy link to clipboard
Copied
Thanks so much for the reply. I chose to go with the array and added the following code (my code is in red) :
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
$redirects = array('snj830' => 'promosnj830.php', 'snj141' => 'promosnj141.php', ‘snj416’ => ‘promosnj416’);
header("Location: " . $redirects[$_SESSION[‘MM_Username]] );
}
else {
header("Location: ". $MM_redirectLoginFailed );
The re-direct on a failed logon is working successfully, but if I enter one of my 3 valid codes, the following screen is displayed:
Index of /boundsauctions.com/promopages
Name Last modified Size Description
errorpage.php 13-Oct-2010 17:24 1.9K
promo _login.php 15-Oct-2010 17:40 5.6K
promosnj141.php 15-Oct-2010 16:00 6.2K
promosnj416.php 15-Oct-2010 15:54 4.6K
promosnj830.php 15-Oct-2010 15:55 4.6K
As you can see, the last three pages here are the ones that I am trying to display. Can you tell what I'm doing wrong?
Copy link to clipboard
Copied
OmarJenkintown wrote:
header("Location: " . $redirects[$_SESSION[‘MM_Username]] );
The closing quote is missing from $_SESSION['MM_Username']. It should be:
header("Location: " . $redirects[$_SESSION['MM_Username']]);