title: hide table in php using session
body: <p>how can i hide the following table in php using session.
  (i dont want the logged in user to see the login table again instead of it i want to show that user's information there til the session is alive)how can i do this please help me friend.</p>
  
  <pre><code>&lt;form name="form1" method="post" action="checklogin.php"&gt;
  &lt;td&gt;
  &lt;table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF" class="post"&gt;
  &lt;tr&gt;
  &lt;td colspan="3"&gt;&lt;h2&gt;&lt;strong&gt;Member Login &lt;/strong&gt;&lt;/h2&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td width="78"&gt;Username&lt;/td&gt;
  &lt;td width="6"&gt;:&lt;/td&gt;
  &lt;td width="294"&gt;&lt;input name="myusername" type="text" id="myusername" maxlength="65"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Password&lt;/td&gt;
  &lt;td&gt;:&lt;/td&gt;
  &lt;td&gt;&lt;input name="mypassword" type="password" id="mypassword" maxlength="65"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and coding for that "checklogin.php" is as follows</p>
  
  <pre><code>&lt;?php
  ob_start();
  $host="localhost"; // Host name
  $username="root"; // Mysql username
  $password="123"; // Mysql password
  $db_name="test"; // Database name
  $tbl_name="member"; // Table name
  
  // Connect to server and select databse.
  mysql_connect("$host", "$username", "$password")or die("cannot connect");
  mysql_select_db("$db_name")or die("cannot select DB");
  
  // Define $myusername and $mypassword
  $myusername=$_POST['myusername'];
  $mypassword=$_POST['mypassword'];
  
  // To protect MySQL injection (more detail about MySQL injection)
  $myusername = stripslashes($myusername);
  $mypassword = stripslashes($mypassword);
  $myusername = mysql_real_escape_string($myusername);
  $mypassword = mysql_real_escape_string($mypassword);
  
  $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  $result=mysql_query($sql);
  
  // Mysql_num_row is counting table row
  $count=mysql_num_rows($result);
  // If result matched $myusername and $mypassword, table row must be 1 row
  
  if($count==1){
  // Register $myusername, $mypassword and redirect to file "login_success.php"
  session_register("myusername");
  session_register("mypassword");
  
  echo("&lt;SCRIPT LANGUAGE='JavaScript'&gt;window.alert('you have logged in successfully')&lt;/SCRIPT&gt;");
  echo("&lt;SCRIPT LANGUAGE='JavaScript'&gt;window.location = 'main_login.php'&lt;/SCRIPT&gt;");
  
  //header("location:login_success.php");
  //window.location = 'login_success.php'
  //echo "&lt;script&gt;navigate('login_success.php')&lt;/script&gt;";
  //exit();
  
  }
  else {
  echo "Wrong Username or Password";
  include 'main_login.php';
  }
  
  ob_end_flush();
  ?&gt;
  </code></pre>