Hi there I am hoping that someone could help me with this... I was trying to redirect a page using header(); after successful login. I am going to share my codes:
Login.html
<html>
<head>
<title>HCPSMSHS: Grade Viewing System</title>
<link rel="stylesheet" href="css.css" type="text/css" charset="UTF-8" media="all">
</head>
<BODY>
<center><div id="header"></div></center>
<center>
<div id="links">
<ul class="navheader">
<li><a href="home.html"><img src="home.png"></a></li>
<li><a href="event.html"><img src="calendar.png"></a></li>
<li><a href="grade.html"><img src="user.png"></a></li>
</ul>
</div>
</center>
<center><div id="content"></div></center>
<center><div id="subcontent">
<div align="justify">
<font face="Courier New" size="1px" color="#aeaeae">
February 6, 2011, 8:21pm</font><br/>
<font face="georgia" size="5px">
Log in</font>
<hr>
<center>
<form name="myform" action="script1.php" method="post">
<table width="500" border="0" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td width="30%" height="40">
<font size="5px">User Name</font>
<td><input type="text" name="username" size="40px" maxlength=25> <br/>
<tr>
<td width="30%" height="40">
<font size="5px">Password</font>
<td><input type="password" name="password" size="40px" maxlength=25> <br/>
<tr>
<td colspan="2"><center><input type="submit" name="submit" width="5"> <input type="button" value="Cancel"></center>
</table>
</form>
</center>
</div></center>
</html>
Script1.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="css.css" type="text/css" charset="UTF-8" media="all">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$conn=odbc_connect('MS Access Driver','','')
or die("connect error: ".odbc_error());
$username=trim(stripslashes($_POST['username']));
$password=trim(stripslashes($_POST['password']));
$sql="SELECT * FROM tbllogin WHERE username='$username' and password='$password'";
$result=odbc_exec($conn,$sql)
or die ("result error ".odbc_error().'-'.odbc_errormsg());
// if no result: no rows read
if (!odbc_fetch_row($result))
{
echo "<script>alert(\"ERROR! Try again.\");</script>";
}
// else: all is okay
else {
$_SESSION['username']=$username;
$_SESSION['password']=$password;
echo "<script>alert(\"Welcome $username!!\")</script>";
header("Location: grade.php");
}
odbc_close($conn);
?>
</body>
</html>
When I try to load these I receive this error:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\web\script1.php:10) in C:\xampp\htdocs\web\script1.php on line 36
line 36 points to the header() code. >.<
can anyone help me with these?