Actually, I am making a table of to-do tasks, beside each task title there is a virtual submission form, with only a submit input button, when it's clicked, a data is inserted into the database using the $_POST[] method. What I need is that after submission, the user must not be able to submit the same task another time, since each task must be done by the user only one time. So I need to let the specific submit button of the task the user made, to get DISABLED PERMANENTLY!. In my approach, the button is being disabled ONCE I'm submitting the task, but after REFRESHING/RELOADING the page, the button is being ENABLED alone. WHICH NOT WHAT I NEED.. ANY APPRECIATED HELP?
Code of making a submit button beside each task (so many forms with many submit button is being created, I differ between them by their ID=(incremental i) and NAME=(id of task, in order to retrieve it by post method) ) :
<?php
$membergroup=$_SESSION['membergroup'];
$sql="select * from taskstable where task_group_name=\"$membergroup\" ";
$result2=mysqli_query($db,$sql);[![enter image description here][1]][1]
$i=0;
while($taskstable=mysqli_fetch_array($result2))
{
$taskPoints=$taskstable['task_points'];
$taskID=$taskstable['task_id'];
print"
<tr>
<td>".$taskstable['task_title']."</td>
<td >".$taskstable['task_description']."</td>
<td style=\"text-align:center;\">".$taskstable['task_points']."</td>
<td>
<form action=$pagename method=\"post\" enctype=\"multipart/form-data\">
<input type=\"submit\" id=\"".$i."\" name =\"$taskID\" class=\"form-control\" value=\"إرسال\" style=\"background-color:#2b3062;width:85%;margin:auto;float:none;color:white;text-align:center;\">
</form>
</td>
</tr>
";
$i++;}
?>
And then, the code of checking whether any of the submit task buttons is being clicked, by post method.
$sql5="SELECT * from taskstable where task_group_name='$membergroup' ";
$result5=mysqli_query($db,$sql5);
while($row=mysqli_fetch_array($result5)){
$taskID2=$row['task_id'];
if(isset($_POST[$taskID2])) {
$query = "select * from taskstable where task_group_name='$membergroup' AND task_id='$taskID2'";
$result7 = mysqli_query($db,$query);
$row2=mysqli_fetch_array($result7);
$taskTitle2=$row2['task_title'];
$oneTaskPoint=$row2['task_points'];
$sql6="INSERT into tasksubmitted(member_username,task_title,task_group_name) VALUES('$uname',N'$taskTitle2','$membergroup');";
$result6=mysqli_query($db,$sql6);
if(!$result6)
echo "<script language='JavaScript'>alert('Error in the query!');</script>";
else
{
$memberPoints+=$oneTaskPoint;
$flag=true;
echo"<script language='JavaScript'>$(\"input[name='$taskID']\").prop('disabled',true)</script>";
}
}
}