Jump to content

post method


ramiwahdan

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.