i have the following code in my login page
<FORM METHOD=POST ACTION='<?php echo $_SERVER['PHP_SELF'];?>'>
<table width="80" border="0" cellspacing="0" cellpadding="5" align="center">
<tr align="left">
<td>User ID: </td>
<td><input type="text" name="username" size="8" maxlength="8" value=""></td></tr>
<tr align="left">
<td>Password: </td>
<td><input type="password" name="password" size="10" maxlength="10"></td></tr>
</table>
<br>
<center><input type="submit" name="submit" value="Login"></center>
</form>
<br>
</table>
<?php
//connect to database
$connection=mysql_connect("localhost","luminosity","luminous") or die ("unable to connect to the database server");
$db = mysql_select_db("luminosity",$connection) or die ("Unable to select the database");
$query = "SELECT Student.Studentno, Student.Password, Student.Name FROM Student WHERE Student.Studentno= '".$_POST['username']." '";
$result = mysql_query($query, $connection);
if(mysql_num_rows($result)){
while ($row = mysql_fetch_array($result)) {
$name=$row['Name'];
if($password == $row['Password']){
echo"<center><tr><td>Welcome ".$name." <a href='".index1 . ".php'> " . " click here" . "</a> to access the system.</td></tr></center>";
}
}
}
?>
how do i incorporate sessions into this script that work over a few pages. i would like the easiest way please.
i have tried session_start() and session_id() at the start of each page but i'm getting nowhere.
hopesomeone can quickly help.