Jump to content
MakeWebGames

Page Redirection.


Jake
 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • 1 month later...

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...