php - Logged in user from session -


hey question on session. trying reflect logged on user's username in form in 1 of webpage. data reflecting person username database. how make reflect person logging on username on form? have necessary data in database. want reflect on form existing user logged in.

    <?php session_start();  ?>     <?         $con=mysqli_connect("","","","");         // check connection         if (mysqli_connect_errno()) {             echo "failed connect mysql: " . mysqli_connect_error();         }          $result = mysqli_query($con, "select `name` `student_details` `name` =  '" . $adminname . "';");         $row = mysqli_fetch_assoc($result);     ?>      <td height="170">       <table>         <form method= "post" action="">           <tr>             <td>student name</td>             <td><input name="admin_no" type= "text" disabled="disabled" value= "<?php echo $row['name'] ?>"        size="40" readonly>              </td>           </tr> 

this how login page looks like

?php session_start(); ?> <?php    include("database.php");      $adminname = $_post['txtname'];     $adminpassword = $_post['txtpassword'];    $conn = dbconnect();      if (!$conn)         die("couldn't connect mysql");      $query = "select * ohrm_user user_name='$adminname' , user_password= '$adminpassword'";     $result = mysql_query($query, $conn);   $row = mysql_fetch_array($result);              $query2 = "select * ohrm_user user_name='$adminname' , user_password= '$adminpassword'";     $result2 = mysql_query($query2, $conn);   $row2 = mysql_fetch_array($result2);                  $query3 = "select * ohrm_user user_name='$adminname' , user_password= '$adminpassword'";     $result3 = mysql_query($query3, $conn);   $row3 = mysql_fetch_array($result3);      if(mysql_num_rows($result) > 0 && $row['user_role_id'] == 1)     {     $_session['user_name'] = $adminname;   $_session['user_password'] = $adminpassword;      header('location: adannouncement.php');     }    elseif   (mysql_num_rows($result2) > 0 && $row2['user_role_id'] == 2) {     header('location: home.php'); }   elseif   (mysql_num_rows($result3) > 0 && $row3['user_role_id'] == 3) {     header('location: sipm_template.php'); } else{ echo "<script type='text/javascript'>alert('wrong username or password'); window.location='login.php'; </script>";     }       dbdisconnect($conn);  ?> 


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -