First of all, I am totally new to PHP and databases in general. I have a question regarding the creation of a website, in which I've created a database that users can login into and interact with. To be more specific, I created a music store website that users can login into and then they choose their favorite disks and add them to their "Favorites List" by using a button of the same name. Below my code so far, only for the favorites portion
<table>
<tr>
<td>
<div class="container" style="height:150px; width: 250px;">
<img src="images\ironmaiden2.jpg" style="height:160px; width:250px;" >
<div class="middle">
<div class="text2" id="1"><a href="https://www.youtube.com/watch?v=FhBnW7bZHEE" target="_blank" style="color:white;">The Writing and the Wall</a></div>
</div>
</div>
<h4><a href="ironmaiden.html">Iron Maiden</a></h4>
<form name="favorite" action="favorite.php" method="post">
<input type="submit" name="submit" value="Add to Favorites">
</form>
</td>
and next my code for the PHP portion,
<?php
//header("Location: login.php");
require_once 'credent.php';
$connecionstr="host=".DB_SERVER." port=5432 dbname=".DB_BASE."
user=".DB_USER." password=".DB_PASS." options='--client_encoding=UTF8'";
$dbconn = pg_connect($connecionstr);
if (!$dbconn) {
die("Connection failed: " . pg_connect_error());
}
if(isset($_POST["submit"]))
{
if(isset($_POST['favorite'])){
$favorite=$_POST['favorite'];
$sql=pg_query("insert into favorite(id) values('$favorite')");
}
}
pg_close($dbconn);
?>
My problem is that I can't find a way to attach / correlate the logged in user input to the database. I have to create a communication channel that connects the user that has logged in, with the actions he makes in the website, stored in my database. What am I missing???