Jump to content

Strange twist in update script


tobimichigan

Recommended Posts

Hello Code Gents,

 

I get so stretched breaking point when a trusted resuable code refuses to perform:

 

Here's it


<?php 
require_once("includes/start_session.php");

require_once("includes/cn.php");
       $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

$username=$_GET[$_SESSION['username']];

require_once("includes/nav_menu.php");
///updates
$msg="";
$aid=$_GET['aid'];
$staff_id=$_GET['staff_id'];
$come="select * from staff_payrolls where staff_id='$staff_id'";
$q1=mysqli_query($dbc,$come);
$row=mysqli_fetch_array($q1);

  $aid = $row['aid'];
$staff_id = $row['staff_id'];
  $basic = $row['basic'];
    $rent = $row['rent'];
  $pension = $row['pension'];
  	$union = $row['union'];
    $tax = $row['tax'];
	  $net = $row['net'];
	    $gross = $row['gross'];


if (isset($_POST['submit'])) {
 $renti=$basic*0.5;
 $pensioni=$basic*0.05;
 $unioni=$basic*0.03;
 $taxi=$basic*0.02;
 $neti=$basic+$rent;
 $grossi=$basic+$rent+$pension+$tax;


    // Grab the profile data from the POST
    //$staff_id = mysqli_real_escape_string($dbc, trim($_POST['staff_id']));
	$basic = mysqli_real_escape_string($dbc, trim($_POST['basic']));
    $rent = mysqli_real_escape_string($dbc, trim($_POST['rent']));
$union = mysqli_real_escape_string($dbc, trim($_POST['union']));
  $pension = mysqli_real_escape_string($dbc, trim($_POST['pension']));
    $tax = mysqli_real_escape_string($dbc, trim($_POST['tax']));
	  $net = mysqli_real_escape_string($dbc, trim($_POST['net']));
	    $gross = mysqli_real_escape_string($dbc, trim($_POST['gross']));

$error=false;

if (!$error) {
      if (!empty($aid)) {
//UPDATE `ak`.`staff_payrolls` SET `basic` = '' WHERE `staff_payrolls`.`aid` =1;

        
         $sql= "UPDATE `ak`.`staff_payrolls` SET `basic` ='$_POST[basic]', `rent`='$renti',`pension`='$pensioni',`union`='$unioni',`tax`='$taxi',`net` ='$neti',`gross` ='$grossi',`salary_date`=SYSDATE() where `staff_payrolls`.`aid` ='$aid'";

mysqli_query($dbc, $sql);


}
      
  } // End of check for form submission

  }

?>
				<p><strong>Welcome to BODE COSMETICS PAYROLL MANAGEMENT SYSTEM.</strong></p>
				<p><?php echo("Welcome $_SESSION[username]. You can start by the top-pane Navigation")  ;?>
		  <p><?php //echo $err ;

	if (@mysqli_query($dbc, $sql)) { echo 'Record Updated';}
	$query = "SELECT * FROM staff_payrolls WHERE aid = '$aid'";
    $data = mysqli_query($dbc, $query);
    $row = mysqli_fetch_array($data);
	$staff_id = $row['staff_id'];
  $basic = $row['basic'];
    $rent = $row['rent'];
  $pension = $row['pension'];
  	$union = $row['union'];
    $tax = $row['tax'];
	  $net = $row['net'];
	    $gross = $row['gross'];
	?>
        <table>
                	<form name="login" method="post" action="">
                            <tr>
                                <td>
                               <th scope="col"><strong>STAFF UPDATE AREA</strong></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                STAFF ID <th scope="col"><input name="staff_id" type="text" value="<?php echo $row['staff_id']; ?>" disabled="disabled" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                BASIC SALARY<th scope="col"><input name="basic" type="text" value="<?php echo $row['basic']; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                RENT <th scope="col"><input name="rent" type="text" value="<?php echo $rent; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                PENSION <th scope="col"><input name="pension" type="text" value="<?php echo $pension; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                UNION <th scope="col"><input name="union" type="text" value="<?php echo $union; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                TAX <th scope="col"><input name="tax" type="text" value="<?php echo $tax; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                NET <th scope="col"><input name="net" type="text" value="<?php echo $net; ?>" /></th>
                                </td>
                            </tr>
                              <tr>
                                <td>
                                GROSS <th scope="col"><input name="gross" type="text" value="<?php echo $gross; ?>" /></th>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                <th scope="col"><input name="submit" type="submit" value="Update_Salary" /></th>
                                </td>
                            </tr>
                       </form>
                </table>          </p>
			</div>			
			<div class="footer"></div>
		</div>

		<div class="post">
			<div class="header">
				<?php require_once("includes/footer.php");?>

 

The funny thing now is that when I press the submit button, nothing happens. Except for the display of what is in the database.

Link to comment
https://forums.phpfreaks.com/topic/234752-strange-twist-in-update-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.