Have a dropdown box which can have between 1-3 publications in it, depending on which pubs a person has subscribed to:
<?php foreach ($userCurrSubs as $pubChoice) { ?>
<option value="
<?php { echo $pubChoice->redirect_url ?>">
<?php echo $pubChoice->pub_name ?>
</option>
When the user selects his desired publication, he is redirected to a particular URL (redirect_url in the code above). The redirect_url code looks like this:
while($row_Recordset2 = mysql_fetch_assoc($pubResultSet)){
$temppubItem = new PubItem();
$temppubItem->pub_name = $row_Recordset2['pub_name'];
$redirectURLtemp = $redirectURL . $temppubItem->pub_name. "/login/login?Read=";
$redirectURLtemp = $redirectURLtemp . urlencode($fromBasedURL . $temppubItem->pub_name );
$utcCurrentDate = gmdate ('Y-m-d');
$md5Temp = $loginUsername . $utcCurrentDate . 'none' . $Secret;
#error_log("string for md5=".$md5Temp);
$md5Temp = md5($md5Temp);
$redirectURLtemp = $redirectURLtemp . '&Id=' . $loginUsername . '&d=' . $utcCurrentDate . '&r=none' . '&c=' . $md5Temp;
$temppubItem->redirect_url = $redirectURLtemp;
error_log("list URL to choose.. ".$redirectURLtemp);
$userCurrSubs[] = $temppubItem;
};
Let's call the publications: GunsAmmo, FieldStream, and PsychologyToday. (pub_name in the code above)
开发者_Python百科GunsAmmo and FieldStream are working fine. However, when someone selects PsychologyToday, they need to be sent to a completely different URL, like http://www.psychologytoday.com , and not have any of the login business above sent along with it.
(Even better, it would be preferable to have PsychologyToday NOT show up in the list at all, even if they're subscribed to it, but I suspect that would be a tougher nut to crack.)
What's the best way to accomplish this? Am not a programmer, so go easy.
I'm a little confused (especially by your second code snippet). If I'm understanding your question correctly, you should use an onChange event with your element.
Example
<html>
<select onChange="document.location.href=this[selectedIndex].value">
<option value="www.example.com"> Option 1 </option>
</select>
</html>
After this line:
$temppubItem->pub_name = $row_Recordset2['pub_name'];
You would add in something like this:
if ($temppubItem->pub_name == 'PsychologyToday') {
// do your redirect here
header('Location: http://www.psychologytoday.com/');
exit();
}
That would immediately jump out of the flow and redirect them. feel free to place that later in the code instead, if you need to write something to your DB first or something.
Alternatively, you could use an if...else like this:
if ($temppubItem->pub_name == 'PsychologyToday') {
$redirectURLtemp = 'http://www.psychologytoday.com/';
} else {
// do all that complicated stuff here where you set $redirectURLtemp
// with the fancy login stuff
}
// do your redirecting after closing your if/else:
header('Location: ' . $redirectURLtemp);
Ended up reverting to older code which turned out to be working and we hadn't realized it. Here was the fix:
$querySQL = "SELECT pub_name FROM pub_subscriber WHERE (pub_name='GunsAmmo' OR pub_name='FieldStream')" ;
This excludes the "PsychologyToday" publication from the output.
Thanks so much for the help though XP84 and vicTROLLA, will keep your solutions in mind for future use.
精彩评论