Jump to content

Timed Redirect?


twilitegxa

Recommended Posts

How can I redirect the user to the character's profile page after so many seconds (say 5 seconds), after they have accepted the character as their own? They reach the following page after accepting the character:

 

<?php

session_start();

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//verify the scout exists
$verify_scout = "select identity from scouts where
    id = $_GET[id]";
$verify_scout_res = mysql_query($verify_scout, $conn)
    or die(mysql_error());

if (mysql_num_rows($verify_scout_res) < 1) {
    //this character does not exist
    $display_block = "<p><em>You have selected an invalid character.
    Please <a href=\"existing.php\">try again</a></em></p>";
} else {
    //gather rest of profile fields
    $get_scout = "select * from scouts where id = $_GET[id]";
        
    $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error());
    
    while ($scout_info = mysql_fetch_array($get_scout_res)) {
        $scout_id = $scout_info['id'];
        $identity = ucwords($scout_info['identity']);

$accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'");
$accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'");
}
}

?>

<html>
<head>
<title>You Have Accepted Character: <?php print $identity; ?></title>
<style type="text/css" media="screen">
/*<![CDATA[*/
@import url(global.css); 
/*]]>*/
</style>

</head>
<body>
<!-- HEADER -->
<h1 class="logo">Sailor Moon RPG</h1>
<!-- /HEADER -->
<?php include("topnav.php"); ?>
<div id="main">
<?php include("includes/log.php"); ?>
<?php include("mainnav.php"); ?>
<h1 align="center"><?php print $identity; ?>: Accepted</h1>
<h3>You have accepted the existing character, <strong><?php print $identity; ?></strong>.</h3>
</div>
<?php include("bottomnav.php"); ?><!-- FOOTER -->
<!-- FOOTER -->
<div id="footer_wrapper">
<div id="footer">
<p>Sailor Moon and all characters
are<br /> 
trademarks of Naoko Takeuchi.</p>
<p>Copyright © 2009 Liz Kula. All rights reserved.<br />
A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
<div id="foot-nav">
<ul>
<li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
<li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
</ul>
</div>
</div>
</div>
<!-- /FOOTER -->
</body>
</html>

 

And I have used the following script to get the profile before (this displays the identity, and then leads to that character's profile:

 

//show scouts characters
$get_scouts = "select * from scouts where username = '".$_SESSION['userName']."'";
$get_scouts_res = mysql_query($get_scouts, $conn) or die(mysql_error());
    while ($list_scouts = mysql_fetch_array($get_scouts_res)) {
    $identity = ucwords($list_scouts['identity']);
    $topic_id = $list_scouts['id'];
    echo "<ul class=\"character_list\"><li><a href=\"showprofile_scouts.php?id=$topic_id\">$identity</li></ul> ";
    }

Link to comment
Share on other sites

I'm having some trouble getting it to redirect to the correct page. I want it to redirect to the profile of the character that they just accepted. I am guessing I would have to use the id, but I am for some reason not getting it right. Can I even use the meta refresh for this? Or do I need to use the PHP header?

Link to comment
Share on other sites

Does anyone know how I can get the id in this meta tag?

 

<META http-equiv="refresh" content="5;URL=showprofile_scouts.php?id=$topic_id">

 

This isn't working. It's saying that $topic_id is an unknown column in the where clause.

 

Can anyone help?

Link to comment
Share on other sites

On the same page I already have this:

 

//verify the scout exists
$verify_scout = "select identity from scouts where
    id = $_GET[id]";
$verify_scout_res = mysql_query($verify_scout, $conn)
    or die(mysql_error());

if (mysql_num_rows($verify_scout_res) < 1) {
    //this character does not exist
    $display_block = "<p><em>You have selected an invalid character.
    Please <a href=\"existing.php\">try again</a></em></p>";
} else {
    //gather rest of profile fields
    $get_scout = "select * from scouts where id = $_GET[id]";
        
    $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error());
    
    while ($scout_info = mysql_fetch_array($get_scout_res)) {
        $scout_id = $scout_info['id'];
        $identity = ucwords($scout_info['identity']);

$accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'");
$accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'");
}
}

 

Could I not get the id from there?

Link to comment
Share on other sites

No, the query on the page that I want to refresh on should contain the id:

 

//verify the scout exists
$verify_scout = "select identity from scouts where
    id = $_GET[id]";
$verify_scout_res = mysql_query($verify_scout, $conn)
    or die(mysql_error());

if (mysql_num_rows($verify_scout_res) < 1) {
    //this character does not exist
    $display_block = "<p><em>You have selected an invalid character.
    Please <a href=\"existing.php\">try again</a></em></p>";
} else {
    //gather rest of profile fields
    $get_scout = "select * from scouts where id = $_GET[id]";
        
    $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error());
    
    while ($scout_info = mysql_fetch_array($get_scout_res)) {
        $scout_id = $scout_info['id'];
        $identity = ucwords($scout_info['identity']);

$accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'");
$accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'");
}
}

 

See, $scout_id contains the id of the character. I tried:

 

<META http-equiv="refresh" content="5;URL=showprofile_scouts.php?id=$scout_id">

 

In my head tag, but it is saying:

 

Unknown column '$scout_id' in 'where clause'

 

Shouldn't this be working? It's on the same page.

 

<?php

session_start();

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
    or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//verify the scout exists
$verify_scout = "select identity from scouts where
    id = $_GET[id]";
$verify_scout_res = mysql_query($verify_scout, $conn)
    or die(mysql_error());

if (mysql_num_rows($verify_scout_res) < 1) {
    //this character does not exist
    $display_block = "<p><em>You have selected an invalid character.
    Please <a href=\"existing.php\">try again</a></em></p>";
} else {
    //gather rest of profile fields
    $get_scout = "select * from scouts where id = $_GET[id]";
        
    $get_scout_res = mysql_query($get_scout, $conn) or die(mysql_error());
    
    while ($scout_info = mysql_fetch_array($get_scout_res)) {
        $scout_id = $scout_info['id'];
        $identity = ucwords($scout_info['identity']);

$accept_scout_username = mysql_query("UPDATE scouts SET username='$_SESSION[userName]' WHERE id = '$scout_id'");
$accept_scout_available = mysql_query("UPDATE scouts SET available='0' WHERE id = '$scout_id'");
}
}

?>

<html>
<head>
<title>You Have Accepted Character: <?php print $identity; ?></title>
<style type="text/css" media="screen">
/*<![CDATA[*/
@import url(global.css); 
/*]]>*/
</style>
<META http-equiv="refresh" content="5;URL=showprofile_scouts.php?id=$scout_id">
</head>
<body>
<!-- HEADER -->
<h1 class="logo">Sailor Moon RPG</h1>
<!-- /HEADER -->
<?php include("topnav.php"); ?>
<div id="main">
<?php include("includes/log.php"); ?>
<?php include("mainnav.php"); ?>
<h1 align="center"><?php print $identity; ?>: Accepted</h1>
<h3>You have accepted the existing character, <strong><?php print $identity; ?></strong>.</h3>
</div>
<?php include("bottomnav.php"); ?><!-- FOOTER -->
<!-- FOOTER -->
<div id="footer_wrapper">
<div id="footer">
<p>Sailor Moon and all characters
are<br /> 
trademarks of Naoko Takeuchi.</p>
<p>Copyright © 2009 Liz Kula. All rights reserved.<br />
A product of <a href="#" target="_blank">Web Designs By Liz</a> systems.</p>
<div id="foot-nav">
<ul>
<li><a href="http://validator.w3.org/check?uri=http://webdesignsbyliz.com/digital/index.php" target="_blank"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a></li>
<li><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://webdesignsbyliz.com/digital/global.css" target="_blank"><img class="c2" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a></li>
</ul>
</div>
</div>
</div>
<!-- /FOOTER -->
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.