Jump to content

hain

Members
  • Posts

    10
  • Joined

  • Last visited

hain's Achievements

Member

Member (2/5)

0

Reputation

  1. good thank you, but the problem is that the result in the echo is none (nothing is displayed), it will be because the variable is not set as you write above, so please advise why the variable is not transferred from prosess.php to admin.php
  2. This is the problem why I write here, I do not know where the mistake is, so I wonder if anyone sees it here and could tell me what the mistake is or correct it and write here what it was.
  3. Yes, I also tried echo $ _SESSION ['Role'] and it didn't work, so I really don't know what it is, I'm quite desperate after a few days of solving this problem, I'm completely stuck on it.
  4. This is exactly what I need to get the role of the user who logs in to the process.php which should be this: while ($ row = mysqli_fetch_array ($ result)) { $ _SESSION ['Role'] = $ row ['role']; } and then to set it to $ role in admin.php and list it in the echo for the user
  5. Yes, but login works without problems, only $ _SESSION ['Role'] does not want to connect to admin.php from process.php. I just need to solve that.
  6. I have these two files and I need to solve the problem that I need the user data in the role column to be taken when logging in. I have written it so that the data can be extracted from the database, but it does not work for me that it is “forwarded” from process.php to admin.php . Please don’t know what the error is that the admin.php file doesn’t want to load $ _SESSION['Role'] from process.php ? Thanks to everyone for helping and here is the code: process.php <?php require_once('connect.php'); session_start(); if(isset($_POST['Login'])) { if(empty($_POST['Username']) || empty($_POST['Password'])) { header("location:index.php?Empty= Please Fill in the Blanks"); } else { $query="select * from role_test where Username='".$_POST['Username']."' and Password='".md5($_POST['Password'])."'"; $result=mysqli_query($con,$query); if(mysqli_fetch_assoc($result)) { $_SESSION['User']=$_POST['Username']; while($row = mysqli_fetch_array($result) ){ $_SESSION['Role']=$row['role']; } header("location:admin.php"); } else { header("location:index.php?Invalid= Please Enter Correct User Name and Password "); } } } else { echo 'Not Working Now Guys'; } ?> admin.php <?php session_start(); if(!(isset($_SESSION['User']))) { header("Location: index.php"); exit(0); } ?> <!DOCTYPE html> <html> <head> <title>Role</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <?php $_SESSION['Role']=$role; echo $role; ?> </body> </html>
  7. I tried the session but it didn't work out, so I deleted the code and went here to ask if anyone was able to write me what I needed.
  8. Hi, I need code that reads from the roles database and then selects which file from these 3 which I want. For example, the user.php file would be loaded if the user has UName = user, Pass = 124, and Roles = User added to the database. But the admin.php and boss.php files would not appear to him. Then only the user who would have it like UName = admin Pass = 125 and Roles = Admin would see the admin.php file, but he would not see the user.php and boss.php files. And of course the boss.php file would be seen by a user with UName = boss, Pass = 126 and Roles = Boss. Please use only PDO! I need to write this in this code somehow. <?php session_start(); if(!(isset($_SESSION['User']))) { header("Location: index.php"); exit(0); } ?> <!DOCTYPE html> <html> <body> <?php include "config.php"; ?> <!--show for User--> <?php include 'user.php';?> <!--show for Admin--> <?php include 'admin.php';?> <!--show for Boss--> <?php include 'boss.php';?> </body> </html>
×
×
  • 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.