In my buyBook.php I have a form that when it is submitted it will go to check_buy.php that will do the process of inserting. This is what I have in the buyBook.php
<div class="form-group" style="width:1px;width:1px;">
<input type="hidden" name="user_id" value="<?php echo $_SESSION['user_id']?>" />
</div>
And this is what I have in the check_buy.php
$user_id = $_SESSION['user_id'];
.
.
.
$ins = mysql_query("INSERT INTO `librarydb`.`buy` (`user_id`) VALUES ('$user_id');");
Why it isn't inserting? I tried referencing what it is in here PHP $_SESSION error when posting to the database but still no luck.
session_start()somewhere?<form>tag, why aren't you use$_POST['user_id']or$_GET['user_id']instead of$_SESSION['user_id'];insidecheck_buy.php?check_buy.php? and just start adding viasession_start()?session_start(). But this input hidden field will be useless for you. You can remove it as well.