Jump to content

Recommended Posts

Hello, I have searched, and searched, I have found sites that are supposed to help, but they don't. I have two forms of SQL - PHP working. One on my computer, and another on an outer computer web server (free hosting). I develop on my computer (to save bandwidth) and then put it on the server and quickly test it. Well, I'm making a forum, and everything seems to work really well on my computer. When I put it on the server, I had a few header problems. I read about tweaking php system files, but since its not my server, I can't.


Error I get:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 39

Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 40

Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 41
You've been logged in! Click Here to go Back
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 58

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in /home/vhosts/dabgames.3000mb.com/forum/in.php on line 59
[/quote]

All code on the error page, everything is going through (so I know, such as the $_POST items) it just seems to be the header.
[code]
$username = "user10342";
$password = "(Its a secret :) )";
$hostname = "localhost";    
$dbh = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
$selected = mysql_select_db("12141",$dbh)
    or die("Could not select dab");
    $once = 0;
if (isset($_COOKIE['in'])){
    ob_start();
    setcookie("in", "", time()-36000);
    setcookie("upass", "", time()-36000);
    setcookie("id", "",  time()-36000);
    
    ob_end_flush();
    
    echo "You've been logged Out. <a href=index.php> Click Here to go Back</a>";
        //header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header
        //header("Location: index.php"); // Jump to the link

} else {
if (isset($_POST['name']) && isset($_POST['pass']))
{
  $user=$_POST['name'];
  $pass=$_POST['pass'];
  $user=mysql_real_escape_string($user);
  $pass=mysql_real_escape_string($pass);

  $sql22 = "select login, password, id from users where login='$user' and password='$pass'";
  $result22=mysql_query($sql22);

  if (mysql_num_rows($result22) > 0)
  {
      
      ob_start();
      setcookie("in", $user, time()+36000);
    setcookie("upass", $pass, time()+36000);
    header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header
    header("Location: index.php"); // Jump to the link
    ob_end_flush();
     echo("You've been logged in! <a href=index.php> Click Here to go Back</a>");

    
  }
  else
  {
    echo("Whoops!  Wrong user name or password!<a href='index.php'> Click Here to Make an account</a>");
  }
}
$once =0;


$result2 = mysql_query("SELECT name, password, id FROM users where name = '$user' and password = '$pass' ");
while ($row = mysql_fetch_array($result2)) {
    if ($once == 0){
    session_start();
    setcookie("id", $row['id'], time()+36000);
    $once = 1;
    break;
}
}

}[/code]
Link to comment
https://forums.phpfreaks.com/topic/10109-help-with-header-sending/
Share on other sites

[a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=63200\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=63200[/a]

Many people have the same problem. Try to search the forum before posting a question that has been answered extensively.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]
No, I don't have any includes.

Here is the resulting HTML code from the page that has errors.
[code]<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>38</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>39</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>40</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>41</b><br />
You've been logged in! <a href=index.php> Click Here to go Back</a><br />
<b>Warning</b>:  session_start(): Cannot send session cookie - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>58</b><br />
<br />
<b>Warning</b>:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>58</b><br />
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/vhosts/dabgames.3000mb.com/forum/in.php:1) in <b>/home/vhosts/dabgames.3000mb.com/forum/in.php</b> on line <b>59</b><br />
[/code]
Here is the URL to the file-ish. Just type in admin for the username then guest for the password (all lowercase). Then you will get the error page right when you hit login.
[a href=\"http://dabgames.3000mb.com/forum/\" target=\"_blank\"]http://dabgames.3000mb.com/forum/[/a]
That space was from the forum. It's not really there on the code. And there isn't any spaces on the top <?php either. Code of the top:

[code]<?php
$username = "user10342";
$password = " Secret ";
$hostname = "localhost";    
$dbh = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
$selected = mysql_select_db("12141",$dbh)
    or die("Could not select dab");
    $once = 0;

if (isset($_COOKIE['in'])){
[/code]
That is only the top of the code.
No. I'm going to it from a form.
So, on index, I have a form that asks for the username and password, and when you hit login, I get the data through the $_POST command.

It seems the problems are only the cookie and the head( commands.

So,
setcookie("in", "", time()-36000);
setcookie("upass", "", time()-36000);
setcookie("id", "", time()-36000);
and
setcookie("in", $user, time()+36000);
setcookie("upass", $pass, time()+36000);
header('HTTP/1.1 301 Moved Permanently'); // Clean 301 header
header("Location: index.php"); // Jump to the link

are the problemed code.

Here is the Index login code:

[code]
echo "You are not logged in!<br /><form method='POST' action='in.php'>
    <p>Name&nbsp; :&nbsp; <input type='text' rows='1' name='name' cols='20' size='52'><br>
    Passqord&nbsp;&nbsp; :&nbsp; <input type='password' name='pass' size='52'><br>
    <p><input type='submit' value='Log In' name='B1'></p></form>";
    
    }
[/code]
Well, some how I got it.

I (searched for the error and found/)read:
[a href=\"http://www.webmasterworld.com/forum88/1100.htm\" target=\"_blank\"]http://www.webmasterworld.com/forum88/1100.htm[/a]

And tried what the guy on the last post did. And it worked for me too. I think that mabye my cache or something had a bit of the old code too. So, deleting the old one, creating a new text file, might of triggered a complete file refresh or something. I'm not sure. But it works perfect now. Thanks everyone for the help! :)
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.