twilitegxa Posted September 6, 2009 Share Posted September 6, 2009 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> "; } Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 6, 2009 Share Posted September 6, 2009 <META http-equiv="refresh" content="5;URL=http://www.google.com"> refresh time is in seconds. Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 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? Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 7, 2009 Share Posted September 7, 2009 PHP Header is for instant refreshes, PHP can't run once the page loads. You need to use the meta tag :-P And yes, somehow insert the id into the URL in the meta-tag will help. Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 Okay, I will try working with it. Thanks. Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 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? Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 7, 2009 Share Posted September 7, 2009 What's your query that you're obtaining this id from? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 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? Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 7, 2009 Share Posted September 7, 2009 Where are you getting $topic_id from? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 It was on another page, sorry. It was a typo. On this page I am using $scout_id. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 7, 2009 Share Posted September 7, 2009 if you are pulling the query from another page include that page where you are echoing it then output it like <?php include('querypage.php'); ?> <META http-equiv="refresh" content="5;URL="showprofile_scouts.php?id=<?= echo $topic_id;?>"> Quote Link to comment Share on other sites More sharing options...
kratsg Posted September 7, 2009 Share Posted September 7, 2009 It was on another page, sorry. It was a typo. On this page I am using $scout_id. I think that means he's solved it. >.< Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 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> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted September 7, 2009 Share Posted September 7, 2009 you problem your using $_GET directly in the query if you do this parse it go back through all the queties your doing this in and change it to id = {$_GET[id]}"; Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted September 7, 2009 Author Share Posted September 7, 2009 That didn't really change anything. Still getting: Unknown column '$scout_id' in 'where clause' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.