When I register a user I add them to a database and they get an id which is auto generated by auto_increment. Now I'm trying to add that id to a session variable so I can use it on other pages in the website and manipulate their row in the database. This is what I have so far.
This line adds the form inputs to the db when the user registers:
$insert = mysql_query("INSERT INTO users (`email`, `password`) VALUES ('example','values'))");
Then I'm trying to get the user_id into a variable that I can use on other pages of the website. I'm trying this:
if ($insert) {
$select_id = mysql_query("SELECT `id` from `users` WHERE `email` = '$form_input'");
$id_arr = mysql_fetch_array($select_id);
$id_var = $id_arr['id'];
session_start();
$_SESSION["Register"] = $id_var[0];
}
But it doesn't work so I'm trying a var_export to see what's in $id_var and I get a value of '3' which doesn't match the user_id that supposed to be stored in the variable.