Jump to content

confusion with how to set a session to a table colum result


Ibshas25

Recommended Posts

so how would i set these sessions into my login page??????not sure where n what code to use

 

1-rol_projectMng` , sessionàisprojectadmin = rol_projectMng

 

`rol_teamsMng` , sessionàisteamsadmin = rol_teamsMng

 

`rol_rolesMng` , sessionàisrolesadmin = rol_rolesMng

 

`rol_usersMng` , sessionàisusersadmin = rol_usersMng

 

`rol_workBreakDowNMng` , sessionàworkbreakdowadmin = rol_workBreakDowNMng

 

` rol_DashboardMng ` , sessionàdashboardadmin = rol_DashboardMng

 

` usr_issysadmin ` , sessionàissysadmin = rol_DashboardMng

 

` rol_ranklevel ` , sessionàrolranklevel =rol_ranklevel

 

 


<?php
session_start();

if (isset($_POST['username']) && isset($_POST['password']))
{
// if the user has just tried to log in
  $usr_username = $_POST['username'];
  $usr_password = $_POST['password'];

//Connect to your Database
  $conn = mysql_connect("vega.soi.city.ac.uk", "", "") 
or die("Could not connect to MySQL Server: " . mysql_error());

//Select your Database
  mysql_select_db("abhr428") 
or die("Could not select database");

//form query
  $query = 'SELECT * FROM users WHERE usr_username = "'.$usr_username.'" AND usr_password = "'.$usr_password.'" ';
  
//Execute query
  $result = mysql_query($query);

//Count results
  $rowNo = mysql_num_rows($result);
  if ($rowNo > 0)
  {
    // if in the database register the user
    $_SESSION['loggedUser'] = $usr_username;

  mysql_free_result($result);
  mysql_close($conn);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="stylesheet1.css" rel="stylesheet" type="text/css"/>
<style type = "text/css">

#container {
width: 250px;
margin: auto;
float:none;
border:width:200px;height:100px;border:1px solid blue;">


}

#logo1 {
	width: 250 px;
	height: 180 px;		
	float:left;
}


h1 {
    font-size:8pt;
    }

h2 {
font-size:7px;

}

</style>
</head>

<body>
<center>
<div style="width:220px;height:260pt;border:5px solid #FFFFFF;">



  <div id= "logo1"><img src="images/FINALlogo.jpg" width="60" height="50" /></div>
<p><h1> Welcome to Project Book</h1></p>
<h2> The methodology based mobile project management tool</h2>
<br><a href="ProjectSignUp.php">Register</a></br>
<?php
if (isset($_SESSION['loggedUser']))
{
    echo 'You are logged in as: '.$_SESSION['loggedUser'].' <br>';
    //echo '<a href="logoutPage1.php">Log out</a><br>';
//echo '<a href="profile_page.html">Jump to the Profile page</a><br>';
?>
  <br>
  <INPUT TYPE="BUTTON" VALUE="Jump to the Project page" ONCLICK="window.location.href='projectBookAdmin.php'">
  
  <?php
}
else
{
if (isset($usr_username))
{
      //if tried and failed to log in
      echo 'Could not log you in.<br>';
    }
    else 
    {
      // Have not tried to log in or have logged out
      echo 'You are not logged in.<br>';
    }
?>
<form method="post" action="projectBookF.php">
  <table>
    <tr>
      <label> <td>Username: </td></label>
      <td><input type="text" name="username"></td>
    </tr>
    <tr>
      <label><td>Password: </td></label>
      <td><input type="password" name="password"></td>
    </tr>
    <tr>
      <td colspan="2" align="center">
        <input type="submit" value="Log in"></td>
    </tr>
  </table>
</form>
</div>
</center>
<?php
}
  
?>
</div>

</body> 
</html>


i understand but to give access to certain pages would i need to put this code as well in the certain page e.g roles

 


<?php
if (isset($_SESSION['loggedUser']))
{
    echo 'You are logged in as: '.$_SESSION['loggedUser'].' <br>';
    //echo '<a href="logoutPage1.php">Log out</a><br>';
//echo '<a href="profile_page.html">Jump to the Profile page</a><br>';
?>
  <br>
  <INPUT TYPE="BUTTON" VALUE="Jump to the Project page" ONCLICK="window.location.href='projectBookAdmin.php'">
  
  <?php
}
else
{
if (isset($usr_username))
{
      //if tried and failed to log in
      echo 'Could not log you in.<br>';
    }
    else 
    {
      // Have not tried to log in or have logged out
      echo 'You are not logged in.<br>';
    }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.