error on simple paymaent form

Hello to all developers!
I am a basic in php. i must present a practice in class. it contains a code with a simple html form & php function that send some fields (about salary & payment). php function must calculate the amount of salary and show it on browser. Also php send information in form to mysql database.
I use xampp (local host program) and can make html form wit php script for sending data to my sql but i cant write php code for calculating salary & show on browser when submit button is click.
description of Variable in form:
$BasicSalary means regular payment
$Housing means pay for rent a house
$Overtime means hours you stay in office and do unfinished task
$businessHours means regular hours for work in a office
$FractionHours means hours you left work at office
$all-Overtime and $all-Fraction are php function that calculate amount of salary!

please help me to make these code. i attach error picture & file codes.
i apologize error picture is in persian language just look below picture at error “echo” 0 . 0 . 0 !!

[php]

payment
<form method="post" action="">
<p>firs name</p>


last name


Basic Salary


food pay


Over time Hours


business pay per Hour


Fraction Hours



<?php $BasicSalary = ""; $Housing = $sabet/10; $Overtime = ""; $businessHours= ""; $FractionHours = ""; $all-Overtime = $FractionHours*$businessHours*(1/4); $all-Fraction = $FractionHours*$businessHours;

function registeruser($Fname, $Lname, $sabet, $food, $ezafekar, $saatkar, $saatkasr){
$con = mysqli_connect(‘localhost’,‘root’,’’);
mysqli_select_db($con,‘salary’);

mysqli_query($con,"INSERT INTO payment(Fname, Lname, sabet, food, ezafekar, saatkar, saatkasr)
    VALUES('$Fname', '$Lname', '$sabet', '$food', '$ezafekar', '$saatkar', '$saatkasr');");
echo mysql_error();

}

if(isset($_POST[‘submit’]))
{
registeruser($_POST[‘Fname’],$_POST[‘Lname’],$_POST[‘sabet’],
$_POST[‘food’],$_POST[‘ezafekar’],$_POST[‘saatkar’],$_POST[‘saatkasr’]);

          echo  "$home .$Uptime .$kasreKar";
         
          
     }
      
     
         
      ?>

  </body>

[/php]

CSS CODES!

[embed=425,349]x
body
{
background:#669900;
font-family:“Lucida Grande”, Tahoma, Arial, Verdana, sans-serif;
font-size:small;
margin:8px 0 16px;
text-align:center;
}
[/php]


First you need to come up with the formula for determining salary, before you can code it.

Is it $BasicSalary + ($Overtime * Overtime PayRate)?

Once you know the formula, then it should be easier to code.

yes tanks but how can i put this formula in a function ?! ;D

Do you know how to write a function?
Do you know how to pass parameters to a function?
Do you know what a return statement is?
Do you know how to call a function from code?

I am not following how, if this is part of a class assignment, you are not familiar with the parts the code you are writing entails.

Code the Formula first, then worry about putting it into a function.

Show me your formula.

you mean if i put this code:
echo ("$FractionHours*$businessHours*(1/4)");

it shows a calc result?
how we can put it in a function? because it is more profational.

my echo code is correct above?

[php]function CalculateSalary($FractionHours, $businessHours) {
echo ("$FractionHours*$businessHours*(1/4)");
}[/php]

tanks ;D :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service