i have designed a login page like this:
[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Electrical Engineering Dept IITK</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-weight: bold}
.style2 {font-size: 14px}
.style3 {font-size: 18px}
.style4 {font-size: 24px}
.style5 {font-size: 36px}
-->
</style>
</head>
<body bgcolor="#99CCFF">
<form name="form1" method="post" action="../myphp/validate1.php">
<div align="center">
<p> <span class="style1">
</span></p>
<pre><span class="style1"><span class="style2"><span class="style3"><span class="style4"><span class="style5"><label><u>Electrical Engineering Department IIT-KANPUR</u></label></span></span></span></span></span></pre>
<p> </p>
<p><span class="style1"> </span> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="38%" border="0">
<tr>
<th scope="row"><div align="left">
<label>User Name</label>
</div></th>
<td><input name="username" type="text" size="35" maxlength="35"></td>
</tr>
<tr>
<th height="29" scope="row"><div align="left">Password</div></th>
<td><input name="password" type="password" size="35" maxlength="35"></td>
</tr>
</table>
&n bsp;
<p> </p>
<table width="2%" border="0" align="center">
<tr>
<th scope="row"><input type="submit" name="Submit" value="Login"></th>
<td><input type="submit" name="Submit2" value="Cancel"></td>
</tr>
</table>
<p> </p>
<label><u><strong></strong></u></label>
</p>
</div>
</form>
</body>
</html>[/HTML]
this page is calling validate.php which is :
[PHP]<?php
session_start();
$passwords = array("ajohari" =>"anurag",
"knaveen" =>"naveen",
"pkk" =>"kalra",
"anu" =>"anu");
if ($password == $passwords[$username]){
$_SESSION['user']=$username?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Faculy Information of E.E Depatment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset rows="144,*" cols="*" frameborder="NO" border="0" framespacing="0">
<frame src="frame1.php" name="topFrame" scrolling="NO" noresize >
<frameset rows="*" cols="257,*" framespacing="0" frameborder="NO" border="0">
<frame src="frame2.php" name="leftFrame" scrolling="NO" noresize>
<frame src="frame3.php" name="mainFrame">
</frameset>
</frameset>
</html>
<?
exit();
}else{
echo "<H2>Invalid user name or password: access denied.</H2>";
include("../myphp/eeiitk.php");
}
?>[/PHP]
after validating frame3.php page is called which is:
[PHP] <?php
session_start();
$connection = pg_connect("host=localhost dbname=personal user=postgres");
if (!$connection) {
print("Connection Failed.");
exit;
}
$username1=$_SESSION['user'];
$myresult = pg_exec($connection, "SELECT * FROM personal where username='username1'");
for ($lt = 0; $lt < pg_numrows($myresult); $lt++) {
$name = pg_result($myresult, $lt, 0);
$designation = pg_result($myresult, $lt, 1);
$department = pg_result($myresult, $lt, 2);
$telephonework = pg_result($myresult, $lt, 3);
$telephoneres = pg_result($myresult, $lt, 4);
$fax = pg_result($myresult, $lt, 5);
$email = pg_result($myresult, $lt, 6);
$address = pg_result($myresult, $lt, 7);
$areaofinterest = pg_result($myresult, $lt, 8);
$username= pg_result($myresult, $lt, 9);
$image= pg_result($myresult, $lt, 10);
}
?>
<body bgcolor="#FFCC99">
<form name="form1" method="post" action="pupdate.php">
<p> </p>
<table width="575" border="0" cellpadding="1" cellspacing="1">
<tr>
<th width="148" scope="row"><div align="left">
<label>IMAGE</label>
</div></th>
<td width="361">
<div align="center">
<input name="image" type="image" src="../naveen_iitk/photos/pkkalra.jpg" width="320" height="240" border="0">
</div>
</td>
<td width="66">
<div align="center">
<input type="submit" name="Submit" value="Upload">
</div>
</td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>USERNAME</label>
</div></th>
<td>
<div align="left">
<input name="username" type="text" size="60" maxlength="50" readonly="" value="<? echo "$username"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>NAME</label>
</div></th>
<td>
<div align="left">
<input name="name" type="text" size="60" maxlength="50" value="<? echo "$name"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row">
<div align="left">
<label>DESIGNATION</label>
</div></th><td><div align="left">
<input name="designation" type="text" size="60" maxlength="50" value="<? echo "$designation"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>DEPARTMENT</label>
</div></th>
<td>
<div align="left">
<input name="department" type="text" size="60" maxlength="50" value="<? echo "$department"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><div align="left"><label>TELEPHONE(Work)</label>
</label>
</div></th><td><div align="left">
<input name="telephonework" type="text" size="60" maxlength="50" value="<? echo "$telephonework"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left"><label>TELEPHONE (Res)</label>
</label>
</div></th><td><div align="left">
<input name="telephoneres" type="text" size="60" maxlength="50" value="<? echo "$telephoneres"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>FAXNO.</label>
</div></th>
<td><div align="left">
<input name="fax" type="text" size="60" maxlength="50" value="<? echo "$fax"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>EMAIL</label>
</div></th>
<td><div align="left">
<input name="email" type="text" size="60" maxlength="50" value="<? echo "$email"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><div align="left">
<label>ADDRESS</label>
</div></th>
<td>
<div align="left">
<textarea name="address" cols="46" rows="5"><? echo "$address"; ?></textarea>
</div>
</td>
<td> </td>
</tr>
<tr>
<th height="150" scope="row">
<div align="left">
<label>AREA OF INTEREST</label>
</div></th>
<td><div align="left">
<textarea name="areaofinterest" cols="46" rows="8"><? echo "$areaofinterest";?></textarea>
</div>
</td>
<td> </td>
</tr>
</table>
<div align="center">
<input type="submit" name="submit" value="Update">
<input type="reset" name="reset" value="Clear It">
</label>
</label>
</div>
</form>
</body>
</html>[/PHP]
But the session_start is not working. The data from the table is not fetched.
Can u tell me that where I m going wrong.