+ 2
How to run my pho+html program to perform calculations (see description)
I have written the code of html in notepad for payroll management system.. With php code inside for calculations but after clicking submit button it doesn't show the auto results. I have used form tag values are already defined. Kindly help me with this☺
17 ответов
+ 1
You unlikely get help without seeing your whole code to point out the mistakes.
+ 1
Sure..
+ 1
This is the php tag that i have used in html documents in beginning
👇
<?php
extract ($_POST);
if (isset($add))
{
$da = ($dar * $basic)/100;
$hra = ($basic * $hrar)/100;
$tda = ($dar * $ta)/100;
$t1= $basic + $da + $hra + $ta + $tda + $incr;
$nps = [($basic + $da)* 10]/100;
$t2= $nps + $m1 + $m2 + $m3 + $tax + $ces + $hba;
}
?>
Tag below is the value tag for calculations 👇
<td><input name="nps" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''"></td>
This tag is the form post tag.. 👇
<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
+ 1
1) i am gonna check it out.
2) sir i am going to post the codes in segments.
3) No sir td tags are in table tag..
Thankyou so much for stepping towrd my problem😊
+ 1
Serial 1-
<?php
extract ($_POST);
if (isset($add))
{
$da = ($dar * $basic)/100;
$hra = ($basic * $hrar)/100;
$tda = ($dar * $ta)/100;
$t1= $basic + $da + $hra + $ta + $tda + $incr;
$nps = [($basic + $da)* 10]/100;
$t2= $nps + $m1 + $m2 + $m3 + $tax + $ces + $hba;
}
?>
<html>
<head>
<title>pms</title>
</head>
<body>
<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<center>
<H1>PAYROLL MANAGEMENT SYSTEM</H1>
<HR COLOR="BLACK">
<HR COLOR="BLACK">
<!------------------>
<table border="2" cellspacing="3" cellpadding="3"
BORDERCOLOR=""GREY">
<tr>
<td>Employee Name:</td>
<td><input name="name" type="text" size="20"></td>
<td>Rank:</td>
<td><input name="rank" type="text" size="20"></td>
</tr>
<tr>
<td>Address:</td>
<td><input name="add." type="text" size="20"></td>
<td>Gender:</td>
<td><input name="gender" type="radio" >male<input name="gender" type="radio" >female</td></tr>
</table>
<hr size="5" HEIGHT="3" COLOR="GREY">
<!-------------------------->
+ 1
Serial number 2-
<table border="2" cellspacing="3" cellpadding="3"
BORDERCOLOR="GREY">
<caption> <b>Expenses</b></caption>
<tr>
<td>S. No.:</td>
<td><input name="num" type="number" size="10"></td>
<td>D.A. rate:</td>
<td><input name="dar" type="number" size="10"></td>
<td>H.R.A. rate:</td>
<td><input name="hrar" type="number" size="10"></td>
</tr>
<tr>
<td>Basic pay:</td>
<td><input name="basic" type="number" size="10"></td>
<td>D.A.:</td>
<td><input name="da" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''"></td>
<td>H.R.A.:</td>
<td><input name="hra" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''"></td>
</tr>
<tr>
<td>T.A.:</td>
<td><input name="ta" type="number" size="10"></td>
<td>T.A. on D.A.:</td>
<td><input name="tda" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''"></td>
<td>Add. incr.:</td>
<td><input name="incr" type="number" size="10"></td>
</tr>
<tr ><th rowspan="3" >
-x-
+ 1
Serial code 3-
<U>TOTAL</U>:<input name="t1" type="number" size="10"
value="<?php echo $t1 ?>" onfocus="this.value=''">
</td>
</th>
</tr>
</table>
<hr size="5" HEIGHT="3" COLOR="BLACK">
<!--------------------->
<table border="2" BORDERCOLOR="GREY" cellspacing="3" cellpadding="3">
<caption> <b>recoveries</b></caption>
<tr>
<td>N.P.S.:</td>
<td><input name="nps" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''"></td>
<td>C.G.G.I.S.:</td>
<td><input name="m1" type="number" size="10"></td>
<td>C.G.H.S.:</td>
<td><input name="m2" type="number" size="10"></td>
<td>Other:</td>
<td><input name="m3" type="number" size="10"></td>
</tr>
<tr>
<td>TAX:</td>
<td><input name="tax" type="number" size="10"></td>
<td>Edu. cess:</td>
<td><input name="ces" type="number" size="10"></td>
<td>H.B.A.:</td>
<td><input name="hba" type="number" size="10"></td>
<tH><B>TOTAL</B>:</tH>
<td><input name="t2" type="number" size="10" value="<?php echo $t2 ?>" onfocus="this.value=''">
</td>
</tr>
</table>
-x-
+ 1
Code part 4-
<hr size="5" HEIGHT="3" COLOR="GREY">
<!-------------->
<table BORDER="4" BORDERCOLOR="BLACK">
<tr><TD><b><u> REMARK:<BR><P>This Estt. does not
undertake any responsibility for commitments of
financial or otherwise entered into by the individual.
</P></B></U></TD>
</TR>
</TABLE>
<HR SIZE="10" HEIGHT="6" COLOR="BLACK">
<!-------------------->
<INPUT TYPE="submit" VALUE="submit" name="add" class="btn" >
<INPUT TYPE="reset" VALUE="reset" class="btn">
</center>
</form>
</BODY>
</html>
+ 1
This is the full code regarding my payroll management system.
Help me fix this
Thankyou. 😊❤
+ 1
Okk.. Thank you..
But what about the t1 and t2 calculations.?
+ 1
No sir🙁
+ 1
https://code.sololearn.com/WZtA919taz7Y/?ref=app
I did it but still no auto-calculations
I want it to run like after entering every data and by clicking on submit button it displays the auto-calculations
0
Please share your code here so that community can help.
Thank you
0
1. Are you sure $add exists? What is the result of print_r($add)?
2. Check $_POST with print_r() or var_dump() to be sure that all variables from form in $_POST?
3. Are your <td> tags inside of form tag?
0
And what is $nps = [($basic + $da)* 10]/100; ? It is wrang php syntax.
I think, it may be cause of syntax error.
May be you mean something like:
$nps = (($basic + $da)* 10)/100;
0
Do not you have the result in t1 and t2 after fixing nps?
0
After fixing $nps I have them ($t1, $t2) calculated and outputted to the "total" inputs. But I tried it on my local PC (not in sololearn editor). It seems, solo editor does not process php correctly.