Jump to content
xisto Community
Sign in to follow this  
Soviet Rathe

Help With Html Redirection.

Recommended Posts

I've integrated a login system for my forum (IPB) and I can't seem to get the redirection working.

Here is my code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/; <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml/; 	<head>		<meta http-equiv="content-type" content="text/html; charset=<% CHARSET %>" /> 		<title>{$this->ipsclass->lang['stand_by']}</title>		$css<input type="hidden" name="redirect" value="window.history.back(1)"></head>	<body>		<div id="redirectwrap">			<h4>{$this->ipsclass->lang['thanks']}</h4>			<p>$Text<br /><br />{$this->ipsclass->lang['transfer_you']}</p>			<p class="redirectfoot">(<a href="$Url">{$this->ipsclass->lang['dont_wait']}</a>)</p>		</div><center>PLEASE CLICK THE LINK ABOVE AS WE ARE WORKING TO IMPROVE THE LOGIN SYSTEM</center>	</body></html>

 

the input I have right before the head ends is what I'm trying to make work. when a user logs into my site from the main page or another page their directed to a redirection page which directs them to the forums. now my login system works fine but I would like to make it so when a user logs in, they are directed to the last page they were on.

 

This part

<input type="hidden" name="redirect" value="window.history.back(1)">
is the part I think is wrong because the browser gives a 404.

Share this post


Link to post
Share on other sites

I get the strangest feeling that window.history.back() may not be compatible with your current browser.Try this function if you must

<script>function goback() {    history.go(-1);}</script><input type="hidden" name="redirect" value="java script:goback()">

Share this post


Link to post
Share on other sites

Actually I still have a problem, even though that works fine, when it goes back. the page is not updated. so when a user logs in and they are taken back to the page they were on. it still shows them as not logged-in until they refresh the page... any solution to this?

Share this post


Link to post
Share on other sites

since you're using javascript already, try this....

<meta http-equiv="refresh" content="0; http://http://www.redirecturl.com/?f; /><meta http-equiv="pragma" content="no-cache"><script type="text/javascript">window.location.replace('http://http://www.redirecturl.com/?f;

Actually I still have a problem, even though that works fine, when it goes back. the page is not updated. so when a user logs in and they are taken back to the page they were on. it still shows them as not logged-in until they refresh the page... any solution to this?

Share this post


Link to post
Share on other sites

since you're using javascript already, try this....

<meta http-equiv="refresh" content="0; http://http://www.redirecturl.com/?f; /><meta http-equiv="pragma" content="no-cache"><script type="text/javascript">window.location.replace('http://http://www.redirecturl.com/?f;

when I use that it redirects back to the last page instantly, and... still no update so it looks as if the user is still not logged in until they refresh. you can see it here http://forums.xisto.com/no_longer_exists/ (login with username: test and password: test)
Edited by Soviet Rathe (see edit history)

Share this post


Link to post
Share on other sites

The reason why it doesn't update is because of the browser, not necessarily the code you are using. The meta information anwiii provided should go on the page that you'll be redirecting to; the JavaScript, obviously, where you want the redirect to occur.If PRAMGA:NO-CACHE doesn't work, try CACHE-CONTROL:NO-CACHE

<meta http-equiv="cache-control" content="no-cache">

Share this post


Link to post
Share on other sites

The reason why it doesn't update is because of the browser, not necessarily the code you are using. The meta information anwiii provided should go on the page that you'll be redirecting to; the JavaScript, obviously, where you want the redirect to occur.
If PRAMGA:NO-CACHE doesn't work, try CACHE-CONTROL:NO-CACHE

<meta http-equiv="cache-control" content="no-cache">


but I don't want the whole page to not cache, just the login form, btw, I'm messing with the login page so it won't be the same as it was

EDIT>
I cannot use meta tags, maybe this will help.

This is my form for the main site

<?php//log into the database$dbhost = 'localhost';$dbuser = '********';$dbpass = '********';$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die					  ('Error connecting to mysql');$dbname = '**************';mysql_select_db($dbname);?><?php if (isset($_COOKIE["member_id"])) {	if ($_COOKIE["member_id"] == 0) {echo "<form action='/forums/index.php?act=Login&CODE=01' method='post' name='LOGIN'><strong>Username</strong>: <input type='text' size='25' maxlength='64' name='UserName' /><br /><strong>Password</strong>: <input type='password' size='25' name='PassWord' /><br />Remember Me? <input class='checkbox' type='checkbox' name='CookieDate' value='1' checked='checked' /><br /><input class='button' type='submit' name='submit' value='Log In' /> </form><br /><a href='/forums/index.php?act=Reg'>Register</a>";	}	else { // Content that shows up if logged in// get the persons username from the database$query = mysql_query("SELECT `members_display_name` FROM `ibf_members` WHERE `id`=" . mysql_real_escape_string($_COOKIE['member_id']) . " LIMIT 1");//then you need to get the result into an array$result = mysql_fetch_assoc($query);//show the usernameecho "Welcome Back {$result['members_display_name']}";	}}else {echo "<form action='/forums/index.php?act=Login&CODE=01' method='post' name='LOGIN' target='_top'><strong>Username</strong>: <input type='text' size='25' maxlength='64' name='UserName' /><br /><strong>Password</strong>: <input type='password' size='25' name='PassWord' /><br />Remember Me? <input class='checkbox' type='checkbox' name='CookieDate' value='1' checked='checked' /><br /><input class='button' type='submit' name='submit' value='Log In' /></form><br /><a href='/forums/index.php?act=Reg'>Become a Member!</a>";}?>

and here's the code for the member bar on the forums
<if="$this->ipsclass->member['id']"><div id="userlinks">	<p class="home"><b>{$this->ipsclass->lang['logged_in_as']} <a href="{$this->ipsclass->base_url}showuser={$this->ipsclass->member['id']}">{$this->ipsclass->member['members_display_name']}</a></b> ( <a href="{$this->ipsclass->base_url}act=Login&CODE=03&k={$this->ipsclass->md5_check}">{$this->ipsclass->lang['log_out']}</a> )</p>	<p><else /><div id="userlinksguest">	<p class="pcen"><b>{$this->ipsclass->lang['guest_stuff']}</b> ( <a href="{$this->ipsclass->base_url}act=Login&CODE=00">{$this->ipsclass->lang['log_in']}</a> | <a href="{$this->ipsclass->base_url}act=Reg&CODE=00">{$this->ipsclass->lang['register']}</a> )</if><if="$this->ipsclass->member['mgroup'] == $this->ipsclass->vars['auth_group']">	<b><a href="{$this->ipsclass->base_url}act=reg&CODE=reval">{$this->ipsclass->lang['resend_val']}</a></b> ·</if><if="$this->ipsclass->member['g_access_cp'] == 1 AND $this->ipsclass->vars['security_remove_acp_link'] == 0">	<b><a href="{$this->ipsclass->vars['_admin_link']}" target="_blank">{$this->ipsclass->lang['admin_cp']}</a></b> ·</if><if="$this->ipsclass->member['has_blog'] == 1">	<b><a href="{$this->ipsclass->base_url}automodule=blog&req=showblog&mid={$this->ipsclass->member['id']}">{$this->ipsclass->lang['myblog']}</a></b> ·</if><if="$this->ipsclass->member['has_gallery'] == 1">	<b><a href="{$this->ipsclass->base_url}autocom=gallery&req=user&user={$this->ipsclass->member['id']}">{$this->ipsclass->lang['submenu_albums']}</a></b> ·</if><if="$this->ipsclass->member['id']">	<b><a href="{$this->ipsclass->base_url}act=UserCP&CODE=00" title="{$this->ipsclass->lang['cp_tool_tip']}">{$this->ipsclass->lang['your_cp']}</a></b> · <!--UNREAD_TOPICs-->	<if="$this->ipsclass->member['g_view_board']">		· <a href="java script:buddy_pop();" title="{$this->ipsclass->lang['bb_tool_tip']}">{$this->ipsclass->lang['l_qb']}</a>	</if>	· <a href="java script:friends_pop();">{$this->ipsclass->lang['gbl_my_friends']}</a>	</if><if="$this->ipsclass->member['g_use_pm'] AND $this->ipsclass->member['members_disable_pm'] == 0">	· <a href="{$this->ipsclass->base_url}act=Msg&CODE=01">{$msg['TEXT']}</a></if>	</p></div>
so I think what it boils down to is disabling caching on those 2 elements
Edited by Soviet Rathe (see edit history)

Share this post


Link to post
Share on other sites

but I don't want the whole page to not cache, just the login form, btw, I'm messing with the login page so it won't be the same as it was

 

EDIT>

I cannot use meta tags, maybe this will help.

 

This is my form for the main site

Showing us the code won't help you, for there is no way to disable cache for certain HTML elements, only the whole page. The closest thing to what you are asking for is to shove the form into another page and load it from an iframe. Use PHP's header() function to inform the browser that it should not cache the page. Look at Example #2 Caching directives in the PHP manual for the header() function to see how to disable cache.

Share this post


Link to post
Share on other sites

Problem Solved!!!
I found a good script that worked to perfection!

<script LANGUAGE="JavaScript">var refarray = new Array();refarray['designplatoon.net/forums/index.php'] = "http://designplatoon.net/forums/index.php";refarray['designplatoon.net/lol.php'] = "http://designplatoon.net/lol.php";for (var i in refarray) {if (document.referrer.indexOf(i) != -1) window.location.replace(refarray[i]);}</script>

Share this post


Link to post
Share on other sites

ummm i am glad you solved it, but i think this whole problem was on your end. when i logged in to the test account a couple days ago, i had absolutely no problems with the site recognizing me as logged in without refreshing

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.