Jump to content

Recommended Posts

is it so hard for people on these forums to at least glance at the pinned topics first?

[url=http://www.phpfreaks.com/forums/index.php/topic,37442.0.html]http://www.phpfreaks.com/forums/index.php/topic,37442.0.html[/url]

see that topic for your answer.
Link to comment
https://forums.phpfreaks.com/topic/14523-nothing/#findComment-57534
Share on other sites

[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

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.