When you click submit, the selection made goes to the database to the row of the user logged in. Having trouble, the selection doesn't update in DB, I'm not getting any errors so I'm having trouble figuring out what the problem is.
<?php include('connect.php');?>
<?php include('functions.php');?>
<?php include('titlebar.php');?>
<form action="login_success.php" method="POST">
<?php
// Inserts pick selection into DB in row of session user
if(isset($_POST['submitbtn'])) {
$selection = $_POST['selection'];
$pick = $mysqli->query("INSERT INTO users selection VALUE $selection WHERE id='$my_id'");
echo '<p>You have made a selection!</p>';
}
?>
<select id="tm1" name="selection">
<?php
$tt = date("h"); // hours 1-12
$current = date("l jS \of F Y h:i:s A"); // Current date/time
$sundayaftr = strtotime("3:00pm Sunday"); // Sunday MID-afternoon game time
$sundaymorn = strtotime("12:00pm Sunday"); // Sunday afternoon game time
$thurs = strtotime("7:00pm Thursday"); // Thursday night game time
$mon = strtotime("7:00pm Monday"); // Monday night game time
$start = strtotime("6:00am Wednesday"); // Wednesday morning Picks open
$close = strtotime("8:00pm Sunday"); // Sunday night game time
if($current > $thurs){$dis = ' disabled';}else{$dis = '';}echo '<option value="wr"'.$dis.'>Washington Redskins</option>';
if(($current >= $thurs) && ($current < $start)){$dis = ' disabled';}else{$dis = '';}echo '<option value="nyg"'.$dis.'>New York Giants</option>';
?>
</select>
<br>
<input type="submit" value="submit" name="submitbtn" id = "submitbtn">
</form>
Here is the functions.php page to create session of logged in user.
<?php
session_start();
function loggedin(){
if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])){
return true;
} else {
return false;
}
}
if(loggedin()) {
$my_id = $_SESSION['user_id'];
$user_query = $mysqli->query("SELECT username, Fname, password, user_level, type FROM users WHERE id='$my_id'");
$run_user = mysqli_fetch_array($user_query);
$username = $run_user['username'];
$Fname = $run_user['Fname'];
$password = $run_user['password'];
$user_level = $run_user['user_level'];
$user_type = $run_user['type'];
$query_level = $mysqli->query("SELECT name FROM user_level WHERE id='$user_level'");
$run_level = mysqli_fetch_array($query_level);
$level_name = $run_level['name'];
}
?>