Jump to content

nothing


BillyBoB

Recommended Posts

[code]

<?php
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
ob_start();
include("config.php");

if (!$logged[username])
{
if(!$_POST[login])
{
echo("
<center>
<form method=\"POST\">
Username:<br />
<input type=\"text\" size=\"15\" maxlength=\"50\" name=\"username\"><br />
Password:<br />
<input type=\"password\" size\"15\" maxlength=\"50\" name=\"password\"><br />
<input type=\"submit\" name=\"login\" value=\"Login\"><br />
<br />
Not a member yet?<br />
<a href=\"register.php\">Register</a><br />
<a href=\"lostpass.php\">Lost Pass?</a>
</form>
</center>
");
}
if($_POST[login])
{
$username=$_POST['username'];
$password = md5($_POST[password]);

$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
echo("Wrong password or username!");
}else{
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
ob_flush();
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
ob_flush();
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://dreamshowstudios.net\"/>Thank You! You will be redirected");
}
}
}else{
echo("
<center>Welcome <b>$logged[username]</b>!<br />
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"logout.php\">Logout</a>
</center>
");
if($user[rank]>=4) {

if($user[rank]==5) {
echo("
<center>
Hello, Admin<br />
- <a href=\"postnews.php\">Post News</a>
</center>
");
}else{
echo("
<center>
Hello, Moderator<br />
- <a href=\"postnews.php\">Post News</a>
</center>
");
}
}
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/14523-nothing/#findComment-57544
Share on other sites

my post was suggesting using output buffering, of which one of the functions is ob_start().  have a look in the manual if you want to go that route.  very few issues are solvable simply by adding one function, a little reading is always involved.

to fix it, REMOVE OUTPUT BEFORE setcookie().  that was the simpler solution, and the solution first mentioned.  move your <DOCTYPE> output to below where you process the login, and specifically, where you use setcookie().  this may require a restructure of your code (so that you manage to get the DOCTYPE out before you echo anything) such as putting any errors into a variable first and echoing it later, but you've gotta give a little to get anything.
Link to comment
https://forums.phpfreaks.com/topic/14523-nothing/#findComment-57548
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.