Problem Statement: Get value of button in PHP, without form-action-post method.
Overview: Developing a web application to manage time-sheet of employees,
Code(to display pre-defined projects from DB, enter_time.php)
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<form action="enter_time.php" method="post">
<?php if (is_array($separateProjects) || is_object($separateProjects)):?>
<?php foreach ($separateProjects as $val):?>
<?php if(strcmp($_SESSION['project_selected'],$val)==0):?>
<button style="float:left" class="btn-default active-project" name="PROJECT" type="hidden" value="<?php echo $val ?>">
<?php echo $val ?></button>
<?php else: ?>
<button style="float:left" class="btn-default inactive-project" name="PROJECT" type="hidden" value="<?php echo $val ?>">
<?php echo $val ?></button>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
</form>
...
</body>
....
</html>
Code( when user selects particular project, enter_time.php):
function projectDisplay()
{
$_SESSION['project_selected'] =$_POST["PROJECT"];
};
if(isset($_POST['PROJECT']))
{
projectDisplay();
}
Question: How do i get value of button in PHP, without form-action-post method? and save that value on _SESSION variable?.
Reason: When user selects particular project from list (clicks on project name button), entire page gets refreshed, and all other values of the screen example date,task list, etc get reset, and i am storing this project value in _SESSION variable for the further processes.
I am happy to any missing detail(s) if any. Help would be appreciated.