Sim Posted April 20, 2012 Share Posted April 20, 2012 My 2 files: the exact error: Warning: Cannot modify header information - headers already sent by (output started at /home/founder/public_html/orpgcreator.com/createrpg.php:1) in /home/founder/public_html/orpgcreator.com/createrpg.php on line 99 createrpg.php <? include "config.php"; //if creating new game if(isset($_POST['CreateGame'])) { //RESERVED WORDS VAR $reserved_game_names = array("default"); //vars $ip = $_SERVER['REMOTE_ADDR']; $game_server = mysql_real_escape_string($_POST['selectServer']); $game_url = mysql_real_escape_string($_POST['textGameURL']); $game_url_unreal = str_replace(" ", "", strtolower($game_url)); $game_name = mysql_real_escape_string($_POST['textGameName']); $game_desc = mysql_real_escape_string($_POST['textDesc']); $name = mysql_real_escape_string($_POST['textName']); $handle = mysql_real_escape_string($_POST['textHandle']); $email = mysql_real_escape_string($_POST['textEmail']); $pass = mysql_real_escape_string($_POST['textPass']); $goals = mysql_escape_string($_POST['textMsg']); $code = rand(10000,99999); $time = time(); //check if name was left blank if (empty($name)) { //set error message $err .= "Name was left blank...<br>"; } //check if desc is blank if (empty($game_desc)) { $err .= "Description was left blank..<br>"; } //check if email was left blank or invalid if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) || empty($email)) { //set error message $err .= "Email was left blank or incorrect...<br>"; } //check if username in use $result = mysql_query("SELECT ownerID FROM game_owners WHERE ownerHandle='$handle'"); if (mysql_num_rows($result) == 1 || empty($handle)) { //set error message $err .= "Username in use...<br>"; } //check if game url in use or a RESERVED WORD $result = mysql_query("SELECT ownerID FROM game_owners WHERE ownerGameURL='$game_url'"); if (mysql_num_rows($result) == 1 || in_array($game_url, $reserved_game_names) || empty($game_url)) { //set error message $err .= "Game url allready in use...<br>"; } //check if game server exists $result = mysql_query("SELECT serverID FROM game_servers WHERE serverName='$game_server'"); if (mysql_num_rows($result) == 0) { //set error message $err .= "Game server does not exist...<br>"; } else { //get server ID $rec = mysql_fetch_object($result); } //if password empty if(empty($pass)) { $err .= "Admin password was left blank..."; } //check if no errors if(empty($err)) { //insert new user query mysql_query("INSERT INTO game_owners (ownerName, ownerIP, ownerHandle, ownerPass, ownerEmail, ownerActCode, ownerGameURL, ownerGameURLReal, ownerGameServerID, ownerGameGoals, ownerRegDate) VALUES ('$name', '$ip', '$handle', '$pass', '$email', '$code', '$game_url_unreal', '$game_url', '$rec->serverID', '$goals', '$time')") or die(mysql_error()); //fetch latest game $result = mysql_query("SELECT ownerID FROM game_owners ORDER BY ownerID DESC LIMIT 1"); $game = mysql_fetch_object($result); mysql_query("INSERT INTO settings(settingType, settingResult, settingGameRefID) VALUES ('gameDesc', '$game_desc', '$game->ownerID')") or die(mysql_error()); mail($email, "oRPG Creator.com New Game Activation", "Please visit http://www.orpgcreator.com/activate.php?server=$game_server&code=$code&game=$game_url_unreal&email=$email", "From: oRPGCreator.com <[email protected]>\n\r"); header("Location: activate.php?email=$email"); //$err = "An email has been dispatched to $email to activate your game from [email protected]"; } } ?> my config.php file <? $dbhost="localhost"; // usually "localhost" $dbname="dd_dumjy"; $dbuser="sdaf_sdaf"; $dbpass="asdfadsfdsaf"; $connection = mysql_connect("$dbhost", "$dbuser", "$dbpass"); mysql_select_db("$dbname", $connection); max_chars = 4; ?> I just dont understand why it just stopped redirecting... :( Quote Link to comment Share on other sites More sharing options...
sniko Posted April 20, 2012 Share Posted April 20, 2012 Try the suppress method @header( [...] ); Or, maybe try the meta refresh? <meta http-equiv="refresh" content="0; url=x" /> Also, remember when you use header or meta refresh put exit; straight after. Quote Link to comment Share on other sites More sharing options...
Sim Posted April 20, 2012 Author Share Posted April 20, 2012 I think i'll go with meta refresh. Forgot about that method. thanks a lot sniko!! Quote Link to comment Share on other sites More sharing options...
Dave Posted April 20, 2012 Share Posted April 20, 2012 You can also enable output buffering and then still use the header redirect. http://uk3.php.net/manual/en/function.ob-start.php Quote Link to comment Share on other sites More sharing options...
Spudinski Posted April 21, 2012 Share Posted April 21, 2012 (edited) Can everyone stop hacking PHP, please? :( Rather find out why contents are being sent before the header(s). By the looks of your script(s), I would suggest that it is a MySQL error or the mail function causing the errors. It's a simple fix either way. Edited April 21, 2012 by Spudinski please stop please? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 3, 2012 Share Posted May 3, 2012 Sorry for the late reply but I had this error yesterday at the start of the file add <?php ob_start(); Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted May 4, 2012 Share Posted May 4, 2012 Which is what Dave had already stated which then prompted Spuds reply followed by SRB's reply. :P Quote Link to comment Share on other sites More sharing options...
Guest Posted May 4, 2012 Share Posted May 4, 2012 Which is what Dave had already stated which then prompted Spuds reply followed by SRB's reply. :P Totally missed his reply :| 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.