MySQL Forums
Forum List  »  PHP

Selecting a variable
Posted by: Rasmus Christiansen
Date: February 21, 2019 05:17PM

Hi everyone.
I'm very new to all this PHP and MySQL, so i'm having a bit trouble.
I have a website were i have made a register and login system, and now i want to make a role system.
Right now i have some problems with selecting the variable role. (I just need to show the role variable number and not the role name). Can anyone figure this out for me?
Here's the code:
if (count($errors) == 0) {
$password = md5($password);
$query = "SELECT * FROM rasmussw_users WHERE username='$username' AND password='$password'";
$results = mysqli_query($db, $query);
if (mysqli_num_rows($results) == 1) {
$results = mysqli_query($db, $query);
$user = mysqli_fetch_assoc($result);
$roleid = $user['roleid'];
$_SESSION['roleid'] = $roleid;
$_SESSION['username'] = $username;
$_SESSION['success'] = "Du er nu logget ind";
header('location: index.php');

<h5 class="col-md-6 col-sm-6" style="text-align: left;">Hej <?php echo $_SESSION['username'] . " " . $_SESSION['roleid']; ?></h5>

Options: ReplyQuote

Written By
Selecting a variable
February 21, 2019 05:17PM
February 21, 2019 07:34PM
February 21, 2019 10:08PM
February 21, 2019 10:19PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.