Jump to content
#FlattenTheCurve ×
ramiwahdan

Button Click Event

Recommended Posts

I have buttons for clocking in and clocking out at my school. When pressed they will get into DB and record current date and time. how to achieve the on click event in 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);
echo("\n");
 ?>

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="form-wrapper"> 
    <center>
	
		<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="button" class="buttonstyle" >Clock Time IN!</button>'; 
											  echo '<button type="button" class="buttonstyle">Clock Time OUT!</button>';} ?>
											  
		<?php if ($row['ClockedOut'] == False and $row['ClockedIn'] == False) {echo '<button type="button" class="buttonstyle" >Clock Time IN!</button>'; 
											  echo '<button type="button" 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="button" class="buttonstyle" >Clock Time IN!</button>'; 
											  echo '<button hidden> type="button" class="buttonstyle">Clock Time OUT!</button>';} ?>
	
	</center>
	
</div>

</body>
</html>

 

Share this post


Link to post
Share on other sites
Posted (edited)

First, don't embed your PHP code like that. Separate your HTML from the PHP code. Second, don't use * in your select. Extract only those variables you plan to actually use. To do what you want, you need to create a form that submits your data when you click one of the buttons. See this article about using forms and passing data to PHP.

Edited by gw1500se
  • Thanks 1

Share this post


Link to post
Share on other sites

Skipping ahead to your actual question - Don't you want to simply do a Submit of your form with that button and not worry about a click?

Share this post


Link to post
Share on other sites

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.