i hav one problem.., i am trying to connect msacess database through odbc using php script; the only thing is it is fectch the data from odbc datasource(adminuser) but it is not redirecting to index.php or any other one.it is giving the error like...
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\projects\admin\index.php:7) in C:\Program Files\Apache Group\Apache2\htdocs\projects\admin\index.php on line 25
above warning giving when we enable disply_errors=on in php.ini file..
my program..
index.php
Code: Select all
<?php
if ($_POST['txtusername'] != null && $_POST['txtpassword'] != '') {
$conn = odbc_connect('admin', '', '');
if (!$conn) {
exit("Connection Failed: " . odbc_errormsg());
} else
echo "Sucessfully connected";
$sql = "SELECT username,password FROM adminuser";
$result = odbc_exec($conn, $sql) or die("Query failed : " . odbc_errormsg());
echo "<br>";
echo $result;
if (!$result) {
echo "Execution failed";
} else echo "<br>";
echo " Query execution successfull";
echo "<br>";
while (odbc_fetch_row($result)) {
$line[1] = odbc_result($result, 1);
$line[2] = odbc_result($result, 2);
print("$line[1] $line[2]\n");
if ($line[1] == ($_POST['txtusername']) && $line[2] == ($_POST['txtpassword'])) {
if ($_POST['check'] == " ") {
header("Location:hai.php");
} else {
header("Location:changepass.php");
}
}
}
odbc_free_result($result);
odbc_close($conn);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="sln.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function setfocus()
{
frm.txtpassword.focus();
}
</script>
</head>
<body onLoad="setfocus();">
<table width="100%" border="0" align="center">
<tr> </tr>
<tr>
<td height="30" align="center" bgcolor="#2C6FDE"><font color="#FFFFFF" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>Welcome
to Our Shop</strong></font></td>
</tr>
<tr>
<td height="361"> <br> <form name="frm" method="post" action="" onSubmit="return validate1(frm);">
<input type="hidden" name="flag" value="1">
<table width="60%" height="300" border="0" align="center" cellpadding="2" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#33CC99">
<tr>
<td colspan="2">
<?php if ($_POST['txtusername'] == null && $_POST['txtpassword'] == '') {
?>
<div align="center" class="txtred12">Please Enter User Name And
Password To Login Into Admin Panel.<br>
<br>
<br>
</div>
<?php
}
?>
<?php
if ($_POST['txtusername'] != null && $_POST['txtpassword'] != '') {
echo "<p align='center'><font color='red' size='3'><b>Warning ! : Please Enter Correct Username and Password.</b></font></p>";
}
?>
</td>
</tr>
<tr>
<td width="29%" class="txtblue11">User Name :</td>
<td width="71%"><input name="txtusername" type="text" class="inptbx" id="Username" value="admin" readonly></td>
</tr>
<tr>
<td class="txtblue11">Password :</td>
<td><input name="txtpassword" type="password" class="inptbx" id="Password" ></td>
</tr>
<tr>
<td><div align="right">
<input type="checkbox" name="check" value="checkbox">
</div></td>
<td class="txtblue11">Check here to change Password</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><div align="right"> </div></td>
<td><input name="Submit" type="submit" class="button" value="Login">
<input name="Submit2" type="reset" class="button" value="Clear"></td>
</tr>
</table>
</form>
<p> </p>
<p> </p></td>
</tr>
<tr> </tr>
</table>
</body>
</html>
hai.php
<html>
<head>
<title>hai</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<em><strong><font size="6" face="Verdana, Arial, Helvetica, sans-serif">hai.........
u r a valid administrator</font></strong></em>
</body>
</html>odbc data source name is "admin" and is located in c:\admin.first i created odbc datasource for that and everything is fine only problem is not redirecting..
admin.mdb
Code: Select all
userid username password
1 admin adminplse can any one help me...
R.S.NAIDU.
feyd | pls can you use
Code: Select all
tags?![/i] [/color]