Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Help With Html Redirection.


10 replies to this topic

#1 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 05 March 2010 - 03:35 AM

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://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<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.

#2 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 05 March 2010 - 04:09 AM

ahh thanks BH, I had already found a solution. here's the code that works
<meta http-equiv="refresh" content="3,java script:window.history.back(1);" />


#3 BuffaloHelp

    Sterling Archer

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 4,088 posts
  • Gender:Male
  • myCENT:50.18

Posted 05 March 2010 - 04:19 AM

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()">


#4 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 05 March 2010 - 04:49 AM

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?

#5 anwiii

    I wont bite...unless you WANT me too

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 2,704 posts
  • Gender:Male
  • Location:Chilhowee, MO
  • Interests:watching grass grow....
  • myCENT:62.06
  • Spam Patrol

Posted 05 March 2010 - 06:02 AM

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

<meta http-equiv="refresh" content="0; http://www.redirecturl.com/" />
<meta http-equiv="pragma" content="no-cache">

<script type="text/javascript">
window.location.replace('http://www.redirecturl.com/')
</script>

View PostSoviet Rathe, on Mar 4 2010, 10:49 PM, said:

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?


#6 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 05 March 2010 - 07:23 PM

View Postanwiii, on Mar 5 2010, 12:02 AM, said:

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

<meta http-equiv="refresh" content="0; http://www.redirecturl.com/" />
<meta http-equiv="pragma" content="no-cache">

<script type="text/javascript">
window.location.replace('http://www.redirecturl.com/')
</script>

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://designplatoon.net/lol.php (login with username: test and password: test)

Edited by Soviet Rathe, 05 March 2010 - 07:23 PM.


#7 truefusion

    Coincidence is non-sequitur, therefore everything has a reason for its existence (except if they are eternal).

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,216 posts
  • Gender:Male
  • Location:No, not there. Not there either. Yes, you'll never figure it out.
  • Interests:God, Christianity.
  • myCENT:86.16

Posted 05 March 2010 - 11:08 PM

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">


#8 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 05 March 2010 - 11:52 PM

View Posttruefusion, on Mar 5 2010, 05:08 PM, said:

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&amp;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 username
echo "Welcome Back {$result['members_display_name']}";
	}
}
else {

echo "<form action='/forums/index.php?act=Login&amp;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&amp;CODE=03&amp;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&amp;CODE=00">{$this->ipsclass->lang['log_in']}</a> | <a href="{$this->ipsclass->base_url}act=Reg&amp;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&amp;CODE=reval">{$this->ipsclass->lang['resend_val']}</a></b> &middot;
</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> &middot;
</if>
<if="$this->ipsclass->member['has_blog'] == 1">
	<b><a href="{$this->ipsclass->base_url}automodule=blog&amp;req=showblog&amp;mid={$this->ipsclass->member['id']}">{$this->ipsclass->lang['myblog']}</a></b> &middot;
</if>
<if="$this->ipsclass->member['has_gallery'] == 1">
	<b><a href="{$this->ipsclass->base_url}autocom=gallery&amp;req=user&amp;user={$this->ipsclass->member['id']}">{$this->ipsclass->lang['submenu_albums']}</a></b> &middot;
</if>
<if="$this->ipsclass->member['id']">
	<b><a href="{$this->ipsclass->base_url}act=UserCP&amp;CODE=00" title="{$this->ipsclass->lang['cp_tool_tip']}">{$this->ipsclass->lang['your_cp']}</a></b> &middot;&nbsp;<!--UNREAD_TOPICs-->
	<if="$this->ipsclass->member['g_view_board']">
		&middot;&nbsp;<a href="java script:buddy_pop();" title="{$this->ipsclass->lang['bb_tool_tip']}">{$this->ipsclass->lang['l_qb']}</a>
	</if>
	&middot;&nbsp;<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">
	&middot;&nbsp;<a href="{$this->ipsclass->base_url}act=Msg&amp;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, 05 March 2010 - 11:58 PM.


#9 truefusion

    Coincidence is non-sequitur, therefore everything has a reason for its existence (except if they are eternal).

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 3,216 posts
  • Gender:Male
  • Location:No, not there. Not there either. Yes, you'll never figure it out.
  • Interests:God, Christianity.
  • myCENT:86.16

Posted 06 March 2010 - 02:17 AM

View PostSoviet Rathe, on Mar 5 2010, 06:52 PM, said:

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.

#10 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 06 March 2010 - 08:36 PM

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>





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users