nooor83
03-30-2006, 01:14 AM
hi guys..
i have this php page..whenever i login successfully..i get the following error
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\ara2\functions.php:47) in C:\wamp\www\ara2\login.php on line 30
here is the login.php page
<?php
require_once("functions.php");
require_once("db_fns.php");
html_header("نظام الدخول");
#session_start();
$error_no = $_GET['error'];
if (isset($_POST['stage']) && ( $_POST['stage'] == 'process'))
{
$username = $_POST['username'];
$password = $_POST['password'];
if ((!$_POST[username]) || (!$_POST[password]))
{
print_login_form(1);
exit;
}
$conn = db_connect();
$sql = "select * from editor where username='" . $username . "' AND password='" . md5($password) . "'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) != 1)
{
print_login_form(2);
}
else
{
header("location: index.php");#echo "تم الدخول بنجاح...اضغط <a href=\"index.php\">هنا</a> للذهاب الى القائمة الرئيسية";
$_SESSION["username"] = $username;
$_SESSION["loginIP"] = $_SERVER["REMOTE_ADDR"];
exit;
}
}
else
{
print_login_form("");
}
function print_login_form($error_no)
{
?>
<table width="300" border="1" align="center">
<form action=<?php echo "\"$_SERVER[PHP_SELF]\""?> method="post">
<tr>
<td align="center" colspan="2">نظام الدحول<input type="hidden" name="stage" value="process">
</td>
<tr>
<td align="right">اسم المستخدم</td>
<td align="right"><input name="username" type="text" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="right">كلمة المرور</td>
<td align="right"><input name="password" type="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="أدخل"></td>
</tr>
<tr>
<td align="center" colspan="2">
<?php
if ($error_no == 1)
{
echo "خانات اسم المستخدم أو كلمة ا لمرور خالية";
}
else if ($error_no == 2)
{
echo "اسم المستخدم أو كلمة ا لمرور غير صحيح";
}
else
{
echo null;
}
?>
</td>
</tr>
</form>
</table>
<?php
}
html_footer();
?>
and here is the functions.php page
<?php
require_once("db_fns.php");
function get_survey()
{
db_connect();
$sql = "select survey_id,survey_topic from survey_topic";
$result = mysql_query($sql) or die(mysql_error());
if (!$result)
return false ;
$poll_data = array();
for ($count=0 ; $row=mysql_fetch_array($result) ; $count++)
{
$poll_data[$count] = $row[0]."|".$row[1] ;
}
return $poll_data;
}
function get_survey_types_name()
{
db_connect();
$sql = "select * from survey_type";
$result = mysql_query($sql) or die(mysql_error());
if (!$result)
return false ;
$poll_data = array();
for ($count=0 ; $row=mysql_fetch_array($result) ; $count++)
{
$poll_data[$count] = $row[0]."|".$row[1] ;
}
return $poll_data;
}
function html_header($title)
{
?>
<html>
<head>
<title><?php echo $title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
</head>
<body dir="rtl">
<?php
}
function html_footer()
{
?>
<div align="center">جميع الحقوق محفوظة© شركة العثمان لخدمات الإنترنت</div>
<div align="center"><font color="White" size="1">Noureddine Elzaatari</font></div>
</body>
</html>
<?php
}
?>
i have this php page..whenever i login successfully..i get the following error
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\ara2\functions.php:47) in C:\wamp\www\ara2\login.php on line 30
here is the login.php page
<?php
require_once("functions.php");
require_once("db_fns.php");
html_header("نظام الدخول");
#session_start();
$error_no = $_GET['error'];
if (isset($_POST['stage']) && ( $_POST['stage'] == 'process'))
{
$username = $_POST['username'];
$password = $_POST['password'];
if ((!$_POST[username]) || (!$_POST[password]))
{
print_login_form(1);
exit;
}
$conn = db_connect();
$sql = "select * from editor where username='" . $username . "' AND password='" . md5($password) . "'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) != 1)
{
print_login_form(2);
}
else
{
header("location: index.php");#echo "تم الدخول بنجاح...اضغط <a href=\"index.php\">هنا</a> للذهاب الى القائمة الرئيسية";
$_SESSION["username"] = $username;
$_SESSION["loginIP"] = $_SERVER["REMOTE_ADDR"];
exit;
}
}
else
{
print_login_form("");
}
function print_login_form($error_no)
{
?>
<table width="300" border="1" align="center">
<form action=<?php echo "\"$_SERVER[PHP_SELF]\""?> method="post">
<tr>
<td align="center" colspan="2">نظام الدحول<input type="hidden" name="stage" value="process">
</td>
<tr>
<td align="right">اسم المستخدم</td>
<td align="right"><input name="username" type="text" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="right">كلمة المرور</td>
<td align="right"><input name="password" type="password" size="20" maxlength="20"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="أدخل"></td>
</tr>
<tr>
<td align="center" colspan="2">
<?php
if ($error_no == 1)
{
echo "خانات اسم المستخدم أو كلمة ا لمرور خالية";
}
else if ($error_no == 2)
{
echo "اسم المستخدم أو كلمة ا لمرور غير صحيح";
}
else
{
echo null;
}
?>
</td>
</tr>
</form>
</table>
<?php
}
html_footer();
?>
and here is the functions.php page
<?php
require_once("db_fns.php");
function get_survey()
{
db_connect();
$sql = "select survey_id,survey_topic from survey_topic";
$result = mysql_query($sql) or die(mysql_error());
if (!$result)
return false ;
$poll_data = array();
for ($count=0 ; $row=mysql_fetch_array($result) ; $count++)
{
$poll_data[$count] = $row[0]."|".$row[1] ;
}
return $poll_data;
}
function get_survey_types_name()
{
db_connect();
$sql = "select * from survey_type";
$result = mysql_query($sql) or die(mysql_error());
if (!$result)
return false ;
$poll_data = array();
for ($count=0 ; $row=mysql_fetch_array($result) ; $count++)
{
$poll_data[$count] = $row[0]."|".$row[1] ;
}
return $poll_data;
}
function html_header($title)
{
?>
<html>
<head>
<title><?php echo $title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
</head>
<body dir="rtl">
<?php
}
function html_footer()
{
?>
<div align="center">جميع الحقوق محفوظة© شركة العثمان لخدمات الإنترنت</div>
<div align="center"><font color="White" size="1">Noureddine Elzaatari</font></div>
</body>
</html>
<?php
}
?>