I had to call session_start() before every output because otherwise it was always giving header output already sent error
here is my full code
When i press login only a blank screen occurs it was working on php4
<?
session_start();
include ("genel.php");
include ("sc.php");
include ("uo.php");
$username = $_POST['username'];
$password = $_POST['password'];
if ($username && $password)
{
$query = "select username,password,yetki from admin where username='$username' and password='$password'";
$result = mysql_query($query);
if (mysql_num_rows($result) > 0)
{
$sonuc = mysql_fetch_row($result);
$admin = new $sonuc[2]($sonuc[0],$sonuc[1],$sonuc[2],0);
$_SESSION['valid_admin'] = $admin;
}
}
?>
<html>
<body>
<h1>Site Yonetim Paneli Login</h1>
<?
if (isset($_SESSION['valid_admin']))
{
echo "Guvenli Bir Sekilde Giris Yaptiniz <br>";
echo "<a href=\"logout.php\">Logout</a><br>";
echo "<a href=\"adminmembers.php?user=$sonuc[0]&plvl=$sonuc[2]\">Account Sistemine Giris</a><br>";
echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=adminpanel.php\">";
}
else
{
if (isset($username))
{
echo "Hatali Login";
}
else
{
echo "Login olmadiniz geri donup login olun";
}
}
?>
<form method="post" action="index.php">
<table>
<tr><td>Username:</tr></td>
<td><input type=text name=username></td></tr>
<tr><td>Password:</tr></td>
<td><input type=password name=password></td></tr>
<tr><td colspan=2 align=center>
<input type=submit value=LogIn></td></tr>
</table></form>
<br>
</body>
</html>
I also have same error on my other site with different code segment
<?
session_start();
header("Content-type: image/jpeg");
if (!isset($_SESSION['userregister'])) //Resim Uzerindeki Yaziyi Yazar
{
$resim_yazi = rand(10,99);
$resim_yazi .= chr(rand(65,90));
$resim_yazi .= chr(rand(65,90));
$resim_yazi .= rand(10,99);
$_SESSION['userregister'] = $resim_yazi; //Sessioni random yaziya esitler
}
$image = imagecreate(118,32);
$bgcolor = imagecolorallocate($image,255,255,0);
$yazicolor = imagecolorallocate($image,0,0,0);
imagefilledrectangle($image,10,10,117,31,$bgcolor);
imagestring($image,5,25,10,$_SESSION['userregister'],$yazicolor);
imagejpeg($image);
?>
even this gives error because of sessions(image created but session didnt)