2017-03-04 93 views
0

不通過此代碼。我有一個模式,其中有一個提交按鈕,每次我必須點擊提交按鈕時,沒有任何操作或者將其插入到數據庫中。我有相同的代碼在相同的文件,具有相同的功能,但另一個工程。所以數據庫插入不是問題。

//REJECTED PROJECT & CHECKING FOR REASON 
if(isset($_POST['rejectSeed'])){ 
    echo "HUY"; 
     $query3="UPDATE projects 
     SET project_status = '7', reason = '".$_POST['reasonSeed']."' 
     WHERE id =".$idProj."";  

     retrieveTable($query3); 
     header('Location: listprojectsprojectproposal.php'); 
} 

enter image description here

echo " 
<div class='modal fade' id='modalRejectSeed' role='dialog'> 
    <div class='modal-dialog modal-lg'> 
     <div class='modal-content'> 
     <div class='modal-header'> 
      <button type='button' class='close' data-dismiss='modal'>&times;</button> 
      <h4 class='modal-title'>Reject ".$strings["project"].": ".$projectDetail->pro_name[0]."</h4> 
     </div> 
     <div class='modal-body'> 
      <h5>Please state the reason why Seed Company rejected the project ".$projectDetail->pro_name[0].". (eg. Insufficient)</h5> 

      <div class='input-group'> 
       <span class='input-group-addon' id='basic-addon1' style='width:500px;'>Reason for Rejection:</span> 
       <input type='text' id='reasonSeed' name='reasonSeed' class='form-control' style='width:500px;' placeholder='' aria-describedby='basic-addon1'> 
      </div> 

     </div> 
     <div class='modal-footer'> 
      <input type='submit' id='rejectSeed' class='btn btn-primary' name='rejectSeed'> 
     </div> 
     </div> 
    </div> 
    </div> 

    "; 
+0

添加一個表單標籤你打開自己高達大規模XSS和SQL注入攻擊。您需要將數據轉換爲HTML並使用參數化的SQL查詢。 –

+0

如果你曾經嘗試'var_dump($ _ POST)',你會看到'rejectSeed'不存在。哦,顯然這個代碼沒有在'

'裏面,所以你提交什麼? – Xorifelse

+0

@Xorifelse嗨,方法$ _POST位於與下面寫的代碼相同的文件。我是否還需要將它放入表單中? –

回答

1

你必須在你的模型

<form action="" method="post"> 
<div class='modal fade' id='modalRejectSeed' role='dialog'> 
<div class='modal-dialog modal-lg'> 
    <div class='modal-content'> 
    <div class='modal-header'> 
     <button type='button' class='close' data-dismiss='modal'>&times;</button> 
     <h4 class='modal-title'>Reject ".$strings["project"].": ".$projectDetail->pro_name[0]."</h4> 
    </div> 
    <div class='modal-body'> 
     <h5>Please state the reason why Seed Company rejected the project ".$projectDetail->pro_name[0].". (eg. Insufficient)</h5> 

     <div class='input-group'> 
      <span class='input-group-addon' id='basic-addon1' style='width:500px;'>Reason for Rejection:</span> 
      <input type='text' id='reasonSeed' name='reasonSeed' class='form-control' style='width:500px;' placeholder='' aria-describedby='basic-addon1'> 
     </div> 

    </div> 
    <div class='modal-footer'> 
     <input type='submit' id='rejectSeed' class='btn btn-primary' name='rejectSeed'> 
    </div> 
    </div> 
</div> 
</div> 
</form> 
+0

不知道提交表單需要提交。你的回答確實有幫助。 –