我无法更新MySQL PHP

问题描述:

我没有收到任何错误,但我无法更新MySQL PHP。我想将下拉状态从“sedang diproses”下拉列表更改为“Berjaya或Tidak Berjaya”。此外,我无法在数据库“sedang diproses”到“成功集团或Tidak成功集团”我无法更新MySQL PHP

改变这是我的代码的HTML

<?php 
    session_start(); 
    include ('include/myFunction.php'); 
    require('include/connect.php'); 
?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>Untitled Document</title> 
    </head> 
    <link href="css/myStyle.css" rel="stylesheet" type="text/css" /> 
    <link href="css/myStyle1.css" rel="stylesheet" type="text/css" /> 
     <!-- Button to open the modal login form --> 
     <link href="css/myStyle3.css" rel="stylesheet" type="text/css" /> 

    <body> 
    <div align="right"> 
     <a href="logout.php" ><img src="img/logout.png" width="63" height="46" /></a> 
    </div> 
    <div class="header" align="left"><a href="#"><img src="img/gmbar.PNG" width="223" height="126" /></a><!-- end .header --><!-- end .header --></div> 
    <div class="content" style="font:Verdana, Geneva, sans-serif"> 
    <div class="content" style="font:Verdana, Geneva, sans-serif"> 
    <div class="topnav" id="myTopnav" style="font-family:Verdana, Geneva, sans-serif"><a href="senaraipemohon.php">Kembali</a> 


    </div> 

    <p>&nbsp;</p> 
     <?php if($_SESSION['namaadmin'] ==null) 
     { 
     header('location:index.php'); 
     } 
     else 
     { 
      ?> 
      <form action="prosesstatus.php" method="post"> 
    <table width="1002" height="87" border="0" align="center" bgcolor="#CCCCFF"> 
     <tr bgcolor="#00CCFF"> 
     <td width="30"><strong>Bil</strong></td> 
     <td width="298"><strong>Nama</strong></td> 
     <td width="176"><strong>Nama Kursus</strong></td> 
     <td width="150"><strong>Tarikh Daftar</strong></td> 
     <td width="150"><strong>Status</strong></td> 
     <td width="168"><strong>Kemaskini Status</strong></td> 
     <td width="131"><strong>Pilihan</strong></td> 

     </tr> 
     <?php 
    $namakursus = ''; 
    if(isset($_GET['namakursus'])) { 
     $namakursus = $_GET['namakursus']; 
    } 

    $sql1 = "Select * from pemohonan INNER JOIN kursus ON pemohonan.idkursus = kursus.idkursus 
     INNER JOIN pemohon ON pemohonan.idPemohon = pemohon.idPemohon WHERE kursus.namakursus = '$namakursus' "; 
    $result1=mysqli_query($dbc,$sql1) or die (mysqli_error()); 
    $i=1; 
     while($row1 = mysqli_fetch_assoc($result1)) 
     { 
    ?> 
     <tr> 

     <td><strong><?php echo $i; ?><input name="idkursus" type="hidden" size="50" value="<?php echo $row1['idkursus'];?>"/><input name="idPemohonan" type="hidden" size="50" value="<?php echo $row1['idPemohonan'];?>"/></strong></td> 
     <td><strong><?php echo $row1['nama']; ?></strong><input name="id" type="hidden" size="50" value="<?php echo $row1['idPemohon'];?>"/></strong></td> 
     <td><strong><?php echo $row1['namakursus']; ?></strong></td> 
     <td><strong><?php echo $row1['tarikhpemohon']; ?></strong></td> 
     <td><strong><?php echo $row1['status']; ?></strong></td> 
     <td><select name="status" value="<?php echo $row1['status']; ?>"> 
       <option value="sila pilih">-Sila Pilih-</option> 
       <option value="Berjaya">Berjaya</option> 
       <option value="Tidak Berjaya">Tidak Berjaya</option> 
       </select></td> 

    <td><input name="btnKemaskini" type="submit" value="Kemaskini" /></td> 

     </tr> 




     <?php 

      $i++; 

     } 
     mysqli_close($dbc); 
     } 

     ?> 
    </table></form> 
    <p>&nbsp;</p> 
    <p>&nbsp;</p> 
    <div class="footer" style="font-family:Arial, Helvetica, sans-serif"> 
    <?php footertext(); ?> 

    </div> 
    </body> 
    </html> 

这是图片 example

这是我自己的DB database

这是我的代码的PHP

<?php 
require ('include/connect.php'); 

$idPemohonan = ''; 
$idPemohon = ''; 
$idkursus = ''; 
if (isset($_GET['idPemohon'],$_GET['idkursus'],$_GET['idPemohonan'])) 
{ 
$idPemohon = $_GET['idPemohon']; 
$idkursus = $_GET['idkursus']; 
$idPemohonan = $_GET['idPemohonan']; 
} 

$tarikhharini=date('y-m-d'); 
$status=$_POST['status']; 

$sql1 = "UPDATE pemohonan SET idPemohonan ='$idPemohonan' , idPemohon ='$idPemohon' , idkursus ='$idkursus' , tarikhpemohon ='$tarikhharini' , status='$status' 
where idPemohonan = '$idPemohonan' and idPemohon = '$idPemohon'"; 

$result1 = mysqli_query($dbc,$sql1) or die (mysqli_error()); 
$num_row1 = mysqli_affected_rows($dbc); 


    echo "<script language=\"JavaScript\">\n"; 
    echo "alert('Status Pemohonan Telah Dihantar!');\n"; 
    echo "window.location='senaraipemohon.php'"; 
    echo "</script>"; 


mysqli_close($dbc); 



?> 
+2

pleeaase ....停止混合标记+逻辑+数据库操作...... _这是我的代码Html_不,它不是!它是所有这些的混合 –

+1

您需要使用mvc架构来组织您的代码。 – Akintunde007

您的代码不工作,因为你没有在 <form action="prosesstatus.php" method="post">

参数发送:

$idPemohon = $_GET['idPemohon']; $idkursus = $_GET['idkursus']; $idPemohonan = $_GET['idPemohonan'];

如果你想使用$ _GET链接应该是这样的: prosesstatus.php?idPemohon=value&idkursus=value&idPemohonan=value

或者你应该添加这些参数在 输入类型隐藏并在php中更改为$ _POST

我同意别人比你应该使用MVC例如某种框架(Laravel,CodeIgniter) 或尽可能分开php和html,因为你的代码看起来不专业。 你的MySQL查询很容易受到SQL注入,最有可能的文件

include/connect.php

不被外部公用文件夹这是不好的做法去做。

+0

感谢您的帮助..也许我还是初学者 – hasyif97

+0

非常抱歉,如果我犯了一些错误 – hasyif97