How can you send session username to the database

Viewed 33

i have tried sending the active session username to the database but it cant get to the database yet i believe i have done everything right. Here is my code:

<?php
  session_start();

  $conn= mysqli_connect("localhost","root","","alex db");
  if(isset($_POST['state'])) {
    $id=$_POST['id'];
    $state=$_POST['input'];
    $name=$_SESSION['username'];
    $sql ="INSERT INTO post(state,vendor_name) values('$state','$name')";
    $query=mysqli_query($conn, $sql);  
  }
?>
0 Answers
Related