Do you have a system to select profile equal to Netflix with different bank?

Asked

Viewed 32 times

0

I created a table in the database with the parent user data, the one who created the account, and created a table that specifies only the child profiles, the ones that are added for each person. Only there is a problem, if I add a different table, obviously it will be necessary to have an auto-increment id for each profile of each account to have an id of its own, but it also needs to contain the id of the parent user of each one to not fall all in the same logged account, This makes up Sesssion I know, but how to make the page select profile read the right profiles of the person who entered?.

Another thing, the profile_id is auto-increment, but the user_id within the table of profiles is not. And nor has it to be, in a table only an auto-increment is allowed.

I was weighing on using while, but changed my mind and will probably need a foreach. As I apply it the right way?

My current login code where the data is stored:

<?php
session_start();
// aqui a conexão
include "core/home/database.php";
//Pega as informações do form
if(empty($_POST['email']) || empty($_POST['senha'])){
        header('Location: signin');
        exit();
    }

$email = @mysqli_real_escape_string($mysqli, $_POST['email']);
$senha = @mysqli_real_escape_string($mysqli, md5($_POST['senha']));

//consulta ao banco de dados

$query = "SELECT * from users, profile where  email = '{$email}' and senha = '{$senha}'";

 $sql = mysqli_query($mysqli, $query);
$bd = @mysqli_fetch_assoc($sql);

// se houver registros, salvamos os dados em variaveis de sessao

if (!empty($bd)) {
    $_SESSION["id"] = $bd["id"];
    $_SESSION["profile_id"]  = $bd["profile_id"];
    $_SESSION["nome"]  = $bd["nome"];
    $_SESSION["sobrenome"]  = $bd["sobrenome"];
    $_SESSION["image"]  = $bd["image"];
    $_SESSION["email"]  = $bd["email"];
    $_SESSION["plan"]  = $bd["plan"];
    $_SESSION["senha"]  = $bd["senha"];
    $_SESSION["cardnumber"]  = $bd["cardnumber"];
    $_SESSION["cardtype"]  = $bd["cardtype"];
    $_SESSION["cardate"]  = $bd["cardate"];
    $_SESSION["cvc"]  = $bd["cvc"];
    $_SESSION["profile1"]  = $bd["profile1"];
    $_SESSION["profile1_id"]  = $bd["profile1_id"];
    $_SESSION["profile1image"]  = $bd["profile1image"];
    $_SESSION["profile2"]  = $bd["profile2"];
     $_SESSION["profile2_id"]  = $bd["profile2_id"];
    $_SESSION["profile2image"]  = $bd["profile2image"];
    $_SESSION["profile3"]  = $bd["profile3"];
    $_SESSION["profile3_id"]  = $bd["profile3_id"];
    $_SESSION["profile3image"]  = $bd["profile3image"];
    $_SESSION["profile4"]  = $bd["profile4"];
    $_SESSION["profile4_id"]  = $bd["profile4_id"];
    $_SESSION["profile4image"]  = $bd["profile4image"];
     $_SESSION["status"]  = $bd["status"];
    
    header("Location: select-profile");
}
if(empty($_SESSION['profile1image']) || empty($_SESSION['profile2image']) || empty($_SESSION['profile3image']) || empty($_SESSION['profile4image'])){
header("Location: select-image-profiles");
}
else{
    header('location: /select-profile');
}

?>

And, yes I did something wrong there because he needs to take the two tables to be able to know first, who is the user who is logged in, and according to which profiles he must display this user logged in select-profile.php. But I’m also lost to see if this is the mistake or if it’s on this page:

  <?php include "language/default.php"; ?>
  <title><?php echo $selectprofile_title ?></title>
    <?php 
  include "./system.php";
include "./language/default.php";
 $email = @mysqli_real_escape_string($mysqli, $_POST['email']);
    $senha = @mysqli_real_escape_string($mysqli, $_POST['senha']);
   $sobrenome = @mysqli_real_escape_string($mysqli, $query);
    $query = "SELECT * from profile where  email = '{$email}' and senha = '{$senha}'";
 
    $result = @mysqli_query($mysqli, $query);
 
    $row = @mysqli_num_rows($result);

    $bd = @mysqli_fetch_assoc($sql);

?>
  <div id="perfis">
<h3 style="font-size: 33px; "><?php echo $sl_whs?></h3>
<?php foreach ($_SESSION as $key => $bd) { ?>
 <span>
  <a href="home?i=<?php echo $key["profile_id"];?>"><img style="width:120px; border-radius: 61px;" src="<?php echo $key["url"] ?>" alt
    <?php echo $_SESSION['profile1']; ?>></a>
  <h4><?php echo $_SESSION['profile1']; ?></h4>
  </span>
  <?php } ?>
  <p>&nbsp</p>
   <a class="btn" href="edit-profile?i=<?php echo $_SESSION['id'];?>"><i class="fa fa-pen"></i> <?php echo $sl_edit ?></a>

  <p style="color:grey; ">Todos os perfis aqui estão conectados a conta do proprietário, edite eles por aqui 
     .
  </p>

And finally the home that should read the selection page, I could not assimilate with the selected profile.

<?php 
    include "./system.php";
include "./language/default.php";
 $email = @mysqli_real_escape_string($mysqli, $_POST['email']);
    $senha = @mysqli_real_escape_string($mysqli, $_POST['senha']);
   $sobrenome = @mysqli_real_escape_string($mysqli, $query);
    $query = "SELECT * from users where  email = '{$email}' and senha = '{$senha}'";
 
    $result = @mysqli_query($mysqli, $query);
 
    $row = @mysqli_num_rows($result);

    $bd = @mysqli_fetch_assoc($sql);

?>
<li id="menuDropDown">
<a name="dropem" href="/account?conta=<?php echo $_SESSION["id"];?>" style="left:-123px"><img style="width:45px;height:45px;border-radius:30px;float:right;position:relative;top:-1em" src="<?php echo $_SESSION['profile1image']; ?>"><label id="icone"></a>
</li>
<li><a href="/logout.php"><i style="position:absolute;top:1em;font-size:22px" class="fa fa-sign-out-alt"></i></a>

How do I make it all work, I want to learn a lot about this type of selection system where you can fit several accounts into one. Thanks in advance

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.