CodeTech Posted March 31, 2011 Share Posted March 31, 2011 Can someone tell me how to fix this At the top of every page i have this. <?php include('GiveAway_Control.php');?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> in the GiveAway_Control.php there is the header("Location: http://www.domain.com/winner.html"); /* Redirect browser */ The GiveAway_Control.php has NO echo statements what so ever. Quote Link to comment https://forums.phpfreaks.com/topic/232247-php-redirect/ Share on other sites More sharing options...
QuickOldCar Posted March 31, 2011 Share Posted March 31, 2011 When you include that redirect, it does just that ...redirects. It doesn't render anything after the redirect. So whatever you need you should place it inside http://www.domain.com/winner.html Quote Link to comment https://forums.phpfreaks.com/topic/232247-php-redirect/#findComment-1194781 Share on other sites More sharing options...
CodeTech Posted March 31, 2011 Author Share Posted March 31, 2011 I have database stuff in the GiveAway_Control.php and depending of the responses, it either redirects or not. I don't see how that helps. If I load the GiveAway_Control.php by its self which has the redirect in it, it all works fine; I just can't get it to work with the include. Another note: if I just have... <?php header("Location: http://www.domain.com/winner.html"); ?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> I get the same error. I don't get it. Warning: Cannot modify header information - headers already sent by (output started at /home/domain/public_html/contact.php:1) in /home/domain/public_html/contact.php on line 2 Quote Link to comment https://forums.phpfreaks.com/topic/232247-php-redirect/#findComment-1194794 Share on other sites More sharing options...
CodeTech Posted March 31, 2011 Author Share Posted March 31, 2011 Ok, I put it all in the same file. Still doesn't work. <?php ////////// MySQL Database Information //////////// $dbservertype='mySQL'; $servername='localhost'; $dbusername='**********'; $dbpassword='**********'; $dbname='**********'; ////////// End Database Information //////// //// Other Information /////// function ConnectToDB($servername,$dbname,$dbuser,$dbpassword) { global $dblink; $dblink = mysql_connect ("$servername","$dbuser","$dbpassword")or die("Couldn't connect to the database."); mysql_select_db("$dbname",$dblink) or die ("Could not select Database".mysql_error()); } ConnectToDB($servername,$dbname,$dbusername,$dbpassword); $VisitorIP=$_SERVER['REMOTE_ADDR']; $result = mysql_query("SELECT Hits FROM Visitors WHERE IP = '$VisitorIP'"); $num_rows = mysql_num_rows($result); if($num_rows){ while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $numHits = $row[0]; } mysql_free_result($result); $newHits = $numHits + 1; mysql_query("UPDATE Visitors SET Hits = '$newHits' WHERE IP = '$VisitorIP' AND Hits = '$numHits'"); } else { /*echo "Unable to match IP";*/ mysql_query("INSERT INTO Visitors (IP, Hits, Date, Time) VALUES ('$VisitorIP', '1', CURDATE(), CURTIME())"); $allrows = mysql_query("SELECT * FROM Visitors"); $TotalVisitors = mysql_num_rows($allrows); mysql_free_result($allrows); if ($TotalVisitors == '7') { header("Location: http://www.domain.com/winner.html"); /* Redirect browser */ exit; } } ?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <body> Why doesn't this work </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/232247-php-redirect/#findComment-1194801 Share on other sites More sharing options...
CodeTech Posted March 31, 2011 Author Share Posted March 31, 2011 Never Mind I changed something and it works now, just not sure what. LOL Quote Link to comment https://forums.phpfreaks.com/topic/232247-php-redirect/#findComment-1194803 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.