Jake Posted January 7, 2007 Share Posted January 7, 2007 This is where rewards can be given for voting: <?php session_start(); require "global_func.php"; if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } $userid=$_SESSION['userid']; require "header.php"; $h = new headers; $h->startheaders(); include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); $fm=money_formatter($ir['money']); $lv=date('F j, Y, g:i a',$ir['laston']); $h->userdata($ir,$lv,$fm); $h->menuarea(); print "[b]You will be redirected to the Apex voting site, in a few seconds Impatient? [url='http://apexwebgaming.com/in/1499']Click Here[/url][/b]"; mysql_query ("UPDATE users SET energy=energy+5 WHERE userid=$userid",$c); header('Location:http://apexwebgaming.com/in/1499'); $h->endpage(); ?> thats what i have, and this is the error i get: Warning: Cannot modify header information - headers already sent by (output started at /home/thelib/public_html/header.php:41) in /home/thelib/public_html/voteapex.php on line 22 Now i hate to be a copy, and paste coder, but i've never done anything like this and i just wondered what i need to change/add/remove from the code to make it work? Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted January 7, 2007 Share Posted January 7, 2007 Re: Page Redirection. how about <?php session_start(); mysql_query ("UPDATE users SET energy=energy+5 WHERE userid='".$_SESSION['userid']."'",$c); header('Location:http://apexwebgaming.com/in/1499'); ?> that should be fine Quote Link to comment Share on other sites More sharing options...
Jake Posted January 7, 2007 Author Share Posted January 7, 2007 Re: Page Redirection. Problem Fixed. Quote Link to comment Share on other sites More sharing options...
vinyl Posted February 17, 2007 Share Posted February 17, 2007 Re: Page Redirection. what am I missing here?? the stock sode gives me the error mentioned above of course, since headers have been sent. and Deceptions solution doesn't prevent multiple voting. not criticizing, but this is making my feeble head hurt even after reading all resources I could find. grrrrrr Quote Link to comment Share on other sites More sharing options...
Jake Posted February 17, 2007 Author Share Posted February 17, 2007 Re: Page Redirection. i use this quite regularly throughout coding now. If you find this, on almost every page: if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } ...You can put all the other redirections in there. If you need to update the SQL table or perform user specifics Ifs, then cut this: include "mysql.php"; global $c; $is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error()); $ir=mysql_fetch_array($is); check_level(); And place it directly above the if you need to perform. Quote Link to comment Share on other sites More sharing options...
Decepti0n Posted February 18, 2007 Share Posted February 18, 2007 Re: Page Redirection. mine was only to fix the original problem lol Quote Link to comment Share on other sites More sharing options...
vinyl Posted February 18, 2007 Share Posted February 18, 2007 Re: Page Redirection. ..and I appreciate that Deception, as i said, I certainly meant no offense. my issue was resolved by changing the voting.php script, apparently there were unclosed items etc dur to a aref. Much simpler than i had feared. Kinda embarrassing since I can usually work these things out w/o asking here. Thanks to you and Jake for responding. It's good to know help is available. 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.