How to specify session to the forms?

Let's say I went to their page I was given cookies
session_start();
include('db.php'); //Connect to database
//Check Dunn user
if(isset($_POST['submit1'])) {
$stmt = $link->prepare("SELECT * FROM accreg WHERE mail = ?");
$stmt->execute([$_POST['mail']]);
$data = $stmt->fetch();

if (password_verify($_POST['password'], $data['password'])){
//assign the cookie
$_SESSION['user_id'] = $data['user_id']; 
$_SESSION['mail'] = $data['mail'];
setcookie('mail', $data['mail'], time()+60*60*24*30); 
header ('Location: acc.php');
} 
else {
 echo "Data is incorrect";
}
}

Now I want to go back to the page via a form of publishing any record
to make this record was just me on the page and not all accounts?
June 10th 19 at 16:30
1 answer
June 10th 19 at 16:32
to make this record was just me

Record - "it"! Female. And commas where?
----
In the form create a hidden field
<input type="hidden" name="myID" value="ID here">

UPD
Not that I'm very blunt, what nafig field.
Just insert your query $_SESSION['user_id'] in a field of need, it is the same you have in the table for "any records", right? So.
And that I do not fully understand the question at first))
and when you create a query in the database this field also need to specify in the query? - fleta87 commented on June 10th 19 at 16:35
I've done the current but I did not go request
$query = $link ->prepare("INSERT INTO `proff` (`user_id`, `avatar`, `lf`) VALUES (:user_id,:avatar,:lf)");//query in the database
 $query -> bindParam(':avatar', $avatar, PDO::PARAM_STR);
 $query -> bindParam(':lf', $lf, PDO::PARAM_INT);
$query->execute();
 }

5a2d28a413e4f664536621.png - fleta87 commented on June 10th 19 at 16:38
I PDO not rummage, but where even a hint of what it is :user_id contains a value from $_SESSION['user_id']? - Leda15 commented on June 10th 19 at 16:41
and isn't she called myself with session_start() ?
And how else if not? - fleta87 commented on June 10th 19 at 16:44
, session_start() initiates the mechanism of sessions. To $_SESSION juzat.
In General that's something like this if no PDO:
session_start();
//....
$query = "INSERT INTO `proff` (`user_id`, `avatar`, `lf`) VALUES (".$_SESSION['user_id'].", 'avatar.jpg', 'some_lf_data')";
 //and post to the database then.

Will not appear in the database - print the echo $query; See what shove.
If rules - copy and in phpMyAdmin -> SQL execute.
You can not simply find a place with the error chtoli?)) - Leda15 commented on June 10th 19 at 16:47
I'm just learning sessions
So I did, but it is not a request
$query = $link ->prepare("INSERT INTO `proff` (`user_id`, `avatar`, `lf`) VALUES (".$_SESSION['user_id'].",:avatar:lf)");//query in the database
 $query -> bindParam(':avatar', $avatar, PDO::PARAM_STR);
 $query -> bindParam(':lf', $lf, PDO::PARAM_INT);
 $query->execute();
- fleta87 commented on June 10th 19 at 16:50
Pancake, well for a day today)) Just paste in the query the value from $_SESSION['user_id']. You somehow the other data is inserted? And so it is!
All I no longer know how to explain))) - Leda15 commented on June 10th 19 at 16:53
you have a certain user ID?) - fleta87 commented on June 10th 19 at 16:56
if you remove the user_id it works but you need to specify the session - fleta87 commented on June 10th 19 at 16:59

Find more questions by tags PHP