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>Electric al 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="#99CCF F">
<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>Elect rical 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"><di v 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"><di v align="left">Pa ssword</div></th>
<td><input name="password" type="password" size="35" maxlength="35"> </td>
</tr>
</table>
&nb sp; &nb sp;
<p> </p>
<table width="2%" border="0" align="center">
<tr>
<th scope="row"><in put type="submit" name="Submit" value="Login"></th>
<td><input type="submit" name="Submit2" value="Cancel"> </td>
</tr>
</table>
<p> </p>
<label><u><stro ng></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>Invali d 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("hos t=localhost dbname=personal user=postgres") ;
if (!$connection) {
print("Connecti on Failed.");
exit;
}
$username1=$_SE SSION['user'];
$myresult = pg_exec($connec tion, "SELECT * FROM personal where username='usern ame1'");
for ($lt = 0; $lt < pg_numrows($myr esult); $lt++) {
$name = pg_result($myre sult, $lt, 0);
$designation = pg_result($myre sult, $lt, 1);
$department = pg_result($myre sult, $lt, 2);
$telephonework = pg_result($myre sult, $lt, 3);
$telephoneres = pg_result($myre sult, $lt, 4);
$fax = pg_result($myre sult, $lt, 5);
$email = pg_result($myre sult, $lt, 6);
$address = pg_result($myre sult, $lt, 7);
$areaofinterest = pg_result($myre sult, $lt, 8);
$username= pg_result($myre sult, $lt, 9);
$image= pg_result($myre sult, $lt, 10);
}
?>
<body bgcolor="#FFCC9 9">
<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"><di v 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"><di v 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"><di v 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>DESIGNAT ION</label>
</div></th><td><div align="left">
<input name="designati on" type="text" size="60" maxlength="50" value="<? echo "$designati on"; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><di v align="left">
<label>DEPARTME NT</label>
</div></th>
<td>
<div align="left">
<input name="departmen t" type="text" size="60" maxlength="50" value="<? echo "$departmen t"; ?>">
</div>
</td>
<td></td>
</tr>
<tr>
<th scope="row"><di v align="left"><l abel>TELEPHONE( Work)</label>
</label>
</div></th><td><div align="left">
<input name="telephone work" type="text" size="60" maxlength="50" value="<? echo "$telephonework "; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><di v align="left"><l abel>TELEPHONE (Res)</label>
</label>
</div></th><td><div align="left">
<input name="telephone res" type="text" size="60" maxlength="50" value="<? echo "$telephoneres" ; ?>">
</div></td>
<td> </td>
</tr>
<tr>
<th scope="row"><di v 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"><di v 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"><di v align="left">
<label>ADDRES S</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="areaofint erest" cols="46" rows="8"><? echo "$areaofinteres t";?></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.