Hi Friends, Please help me on the following:
1. the session gets expired in the php after login by the users!
Iam using the code as follow:
Could anybody help me to find out the problem as to why the session gets expired?
Thanking you in anticipation!
1. the session gets expired in the php after login by the users!
Iam using the code as follow:
Code:
<?php
session_start();
?>
<html>
<head>
<title>
My Profile
</title>
</head>
<body>
<div align=center>
<?php
include("header.php");
include("db_open.php");
printProfile();
include("db_close.php");
include("footer.php");
?>
</div>
</body>
</html>
<?php
function printProfile() {
if( isset($_SESSION['myusername']) ) {
$username = $_SESSION['myusername'];
}
else {
$username = '';
}
echo '<div class=centerfixed>';
echo '<table>';
echo '<tr>';
echo '<td >';
if( $username ) {
printProfileDetails( $username );
}
else {
echo '<p align=center><br/><br/>You are not logged in!!!';
echo '<a href="login.php">Please Login</a>';
echo '</p>';
}
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</div>';
}
function printProfileDetails( $username ) {
$query = 'SELECT * FROM user_info WHERE USER_NAME="'.$username.'"';
$result = mysql_query( $query );
if( !$result ) {
die( "Could not query the database: <br/>".mysql_error() );
}
while( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
$detail = $row['USER_NAME'];
echo '<table align=center class=display>';
echo '<tr class=header>';
echo '<th colspan=2>User Profile Details</th>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Username</th>';
echo '<td class=display>'.$detail.'</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Name</th>';
echo '<td class=display>'.$row['FIRST_NAME'].' '.$row['MIDDLE_NAME'].' '.$row['LAST_NAME'];
echo '</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Education</th>';
echo '<td class=display>'.$row['EDU_QUAL'].'</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Institute Name</th>';
echo '<td class=display>'.$row['INST_NAME'].'</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Job Category</th>';
echo '<td class=display>'.$row['JOB_CATEGORY'].'</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Current Job Location</th>';
echo '<td class=display>'.$row['CURR_JOB_LOC'].'</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Experience</th>';
echo '<td class=display>'.$row['EXPERIENCE'].'</td>';
echo '</tr>';
echo '<tr class=display1 >';
echo '<th class=display>  Current CTC</th>';
echo '<td class=display>'.$row['CURRENT_CTC'].'</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Expected CTC</th>';
echo '<td class=display>'.$row['EXPECTED_CTC'].'</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Joining Time</th>';
echo '<td class=display>'.$row['JOINING_TIME'].'</td>';
echo '</tr>';
$contactid = $row['CONTACT_ID'];
$query = "SELECT * FROM contact_info WHERE CONTACT_ID='$contactid'";
$result1 = mysql_query( $query );
if( !$result1 ) {
die( "Could not query the database: <br/>".mysql_error() );
}
$row1 = mysql_fetch_array($result1, MYSQL_ASSOC);
if( $row1 ) {
echo '<tr class=display>';
echo '<th class=display>  Address</th>';
echo '<td class=display>'.$row1['ADDRESS_1'].' '.$row1['ADDRESS_2'].' '.$row1['ADDRESS_3'];
echo '</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  City</th>';
echo '<td class=display>'.$row1['CITY'];
echo '</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  State</th>';
echo '<td class=display>'.$row1['STATE'];
echo '</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Country</th>';
echo '<td class=display>'.$row1['COUNTRY'];
echo '</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Pincode</th>';
echo '<td class=display>'.$row1['PINCODE'];
echo '</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  Phone</th>';
echo '<td class=display>'.$row1['PHONE_OFF_1'];
echo '</td>';
echo '</tr>';
echo '<tr class=display>';
echo '<th class=display>  Mobile</th>';
echo '<td class=display>'.$row1['MOBILE_1'];
echo '</td>';
echo '</tr>';
echo '<tr class=display1>';
echo '<th class=display>  EMail</th>';
echo '<td class=display>'.$row1['EMAIL_1'];
echo '</td>';
echo '</tr>';
}
echo '</table>';
}
}
?>
Thanking you in anticipation!
Comment