2017-04-21 39 views
-2
<!doctype html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 
<meta http-equiv="x-ua-compatible" content="ie=edge"> 
<link rel="stylesheet" href="css/bootstrap.min.css"> 
<title>Submitted</title> 
</head> 

<body> 
<?php 
$employeeName = $_POST["txt_name"]; 
$employeeEmail = $_POST["txt_email"]; 
$employeeCompany = $_POST["txt_cmp"]; 
$employeeDesignation = $_POST["slc_dsgn"]; 
$employeeSalary = $_POST["txt_slry"]; 
$employeeStatus = $_POST["status"]; 
$employeeReason = $_POST["msg_rsn"]; 


?> 
<div class="container"> 
<table class="table table-inverse"> 
<thead> 
<tr> 
    <th>#</th> 
    <th>Employee Name</th> 
    <th>Email Address</th> 
    <th>Company</th> 
    <th>Designation</th> 
    <th>Salary</th> 
    <th>Status</th> 
    </tr> 
</thead> 
<tbody> 
    <tr> 
    <th scope="row">1</th> 
    <td><?php echo($employeeName)?></td> 
    <td><?php echo($employeeEmail)?></td> 
    <td><?php echo($employeeCompany)?></td> 
    <td><?php echo($employeeDesignation)?></td> 
    <td><?php echo($employeeSalary)?></td> 
    <td><?php echo($employeeStatus)?></td> 
</tr> 

</tbody> 
</table> 
<?php 
if($employeeSalary > 20000){ 
$percentage = 35; 
    $loan = ($percentage/100) * $employeeSalary; 

    } 
    ?> 

    <?php 
    if($employeeSalary > 30000){ 
    $percentage = 25; 
    $loan = ($percentage/100) * $employeeSalary; 

    } 
    ?> 

    <?php 
    if($employeeSalary > 40000){ 
    $percentage = 15; 
    $loan = ($percentage/100) * $employeeSalary; 

    } 
    ?> 
    <div class="text-center display-4 bg-faded justify-content-around"> your Loan will be <?php echo($loan)?> as per your current salary </div> 

    <p class="blockquote text-center justify-content-around"> <?php echo($employeeReason);?> 
    <span class="blockquote-footer">Reason</span> 
    </p> 
    </div> 
    </html> 

這是我的代碼我是小新的PHP當我打開我的本地主機上的頁面好說$百分比取消定義的變量,即使我定義它的每一個,如果條件後來然後我用它來獲得百分比的鹽水,但我也試圖把這個變量全球仍然沒有改變它的價值我的條件我不知道如何排序這如何定義變量,如果條件

Ps這個問題是如此改變我已經嘗試了很多找到類似的,但我無法得到。

+0

'$ _POST'從哪裏來? – Akintunde007

+0

您在哪一行發生此錯誤? – Jerodev

+1

當'$ employeeSalary'較低或等於20000時,您將會收到此錯誤 –

回答

0

嘗試有條件地定義它是這樣的:

if(!isset($percent)){ 
    $percent = 0; 
} 

,將安全定義變量,而不是打亂程序中的任何東西。

+0

它不只是要定義它的變量也我想如果用戶工資是20000那麼他得到35%的貸款,如果它更多它得到更少,因爲我定義它,但不幸的是它不讓我定義變量值它保持顯示錯誤undefine變量 –