ramiwahdan Posted March 9, 2020 Share Posted March 9, 2020 Dear All, I am trying to check which button is clicked inside the same php file and from there i will do some coding, I tried to echo some text but not working. PHP: <?php include('dbcon.php'); include('session.php'); $result=mysqli_query($con, "select * from staff where OracleID='$session_id'")or die('Error In Session'); $row=mysqli_fetch_array($result); if (isset($_POST["inside"])){ echo 'inside'; } else{ echo 'outside'; } ?> HTML: <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="form-wrapper"> <center> <form action="home.php" method="POST"> <h3>Welcome: <?php echo $row['StaffName']; ?> </h3> <?php if ($row['ClockedIn'] == True and $row['ClockedOut'] == False) {echo "You already clockedIn today, please clockOut"; echo '<button hidden> type="submit" class="buttonstyle" >Clock Time IN!</button>'; echo '<button type="submit" name = "out" class="buttonstyle">Clock Time OUT!</button>';} ?> <?php if ($row['ClockedOut'] == False and $row['ClockedIn'] == False) {echo '<button type="submit" name = "inside" class="buttonstyle" >Clock Time IN!</button>'; echo '<button type="submit" name = "out" class="buttonstyle" >Clock Time OUT!</button>';} ?> <?php if ($row['ClockedIn'] == True and $row['ClockedOut'] == True) {echo "You already clockedIn and ClockedOut today!"; echo '<button hidden> type="submit" class="buttonstyle" >Clock Time IN!</button>'; echo '<button hidden> type="submit" class="buttonstyle">Clock Time OUT!</button>';} ?> </form> </center> </div> </body> </html> Please help on this please. Quote Link to comment https://forums.phpfreaks.com/topic/310238-post-method/ Share on other sites More sharing options...
Phi11W Posted March 9, 2020 Share Posted March 9, 2020 One of the elements submitted with the POST request should be the name attribute of the clicked [submit] button. Some of your buttons have the name "out". Some of your buttons have no name at all - they should all have one. None of your buttons have the name "inside", which your PHP code is testing for. Regards, Phill W. Quote Link to comment https://forums.phpfreaks.com/topic/310238-post-method/#findComment-1575279 Share on other sites More sharing options...
ramiwahdan Posted March 9, 2020 Author Share Posted March 9, 2020 I do have button with name "inside", it is there. Quote Link to comment https://forums.phpfreaks.com/topic/310238-post-method/#findComment-1575280 Share on other sites More sharing options...
ginerjm Posted March 9, 2020 Share Posted March 9, 2020 YOu have some problems with your buttons coding. LIke: <button hidden> What is that? Quote Link to comment https://forums.phpfreaks.com/topic/310238-post-method/#findComment-1575281 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.