Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have been having trouble fixing this warning. Below is my code.

<?php
require('db.php');
include("auth_session.php");

 

if(count($_POST)>0) {
    mysqli_query($con, "UPDATE senarai_penggerak set id='" . $_POST['id'] . "',
    loginid='" . $_SESSION['loginid'] ."',
    nama_pengguna='" . $_POST['nama_pengguna'] . "', 
    jawatan='" . $_POST['jawatan'] . "' , 
    tujuan='" . $_POST['tujuan'] . "', 
    keluar='".$_POST['keluar']."', 
    masuk='".$_POST['masuk']."' 
    WHERE id='" . $_POST['id'] . "'");
    $message = "Record Modified Successfully";
    }
    $search_result = mysqli_query($con,"SELECT * FROM senarai_penggerak WHERE id='" . $_GET['id'] . "'");
    $row= mysqli_fetch_array($search_result);
  
  ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/dashboard.css">
    <link rel="stylesheet" href="css/form.css">
    <link rel="stylesheet" href="https://codepen.io/gymratpacks/pen/VKzBEp#0">
    <link href='https://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
    <style>

    </style>
</head>
<body>
   
    <div class="wrapper">
       <div class="section">
    <div class="top_navbar">
      <div class="tigaline">
        <a href="#">
          <i class="fas fa-bars"></i>
        </a>
      </div>
    </div>
    <div class="container">
        <h1><center>Daftar Keluar/Masuk</center></h1><br>
        <div class="row">
    <div class="col-md-12">
    <form name="frmUser" style="margin:130px" action = "" method="POST">
    <div> <?php if(isset($message)) {echo $message;}?></div>
        <br>
        <fieldset>
          
          <label for="Nama">Nama:</label>
          <select id="nama" name="nama_pengguna" value="<?php echo $row['nama_pengguna']; ?>">
            <option value="select" disabled selected>Sila Pilih</option>
            <option value="Mohd Shahrin Bin Ismail">Mohd Shahrin Bin Ismail</option>
              <option value="Mohd Asron Affandi Bin Ahmad Fisho">Mohd Asron Affandi Bin Ahmad Fisho</option>
              <option value="Kasyful Najwan Bin Mohd Kamal">Kasyful Najwan Bin Mohd Kamal</option>
              <option value="Hazirah Bt Jaafar<">Hazirah Bt Jaafar</option>
              <option value="Shafiq Ahmad Bin Mohammad Innus">Shafiq Ahmad Bin Mohammad Innus</option>
              <option value="Siti Nazieha Bt Mohd Nazri">Siti Nazieha Bt Mohd Nazri</option>
              <option value="Suhailawati Bt Jaafar">Suhailawati Bt Jaafar</option>
              <option value="Nur Adam Bin Ismail">Nur Adam Bin Ismail</option>
              <option value="Mohammad Aiman Bin Aminuddin">Mohammad Aiman Bin Aminuddin</option>
              <option value="Nur Izati Binti Ramli">Nur Izati Binti Ramli</option>
           </select>
          
          <label for="jawatan">Jawatan:</label>
          <select id="jawatan" name="jawatan" value="<?php echo $row['jawatan']; ?>">
             <option value="select" disabled selected>Sila Pilih</option>
              <option value="Pegawai Teknologi Maklumat">Pegawai Teknologi Maklumat</option>
              <option value="Pen. Pegawai Teknologi Maklumat">Pen.Pegawai Teknologi Maklumat</option>
              <option value="Pembantu Tadbir">Pembantu Tadbir</option>
              <option value="Pembantu Awam">Pembantu Awam</option>
              <option value="Intern">Intern</option>
             </select>

         <label for="tujuan">Tujuan:</label>
          <textarea id="tujuan" name="tujuan" value="<?php echo $row['tujuan']; ?>"></textarea>
        
          <label for="jam_keluar">Jam Keluar:</label>
          <input type="datetime-local" id="jam_keluar" name="keluar" value="<?php echo $row['keluar']; ?>">
        
          <label for="jam_masuk">Jam Masuk:</label>
          <input type="datetime-local" id="jam_masuk" name="masuk" value="<?php echo $row['masuk']; ?>">
          
         </fieldset> 

        <button type ="submit" style="font-size:24px" name="submit"><i class="fa fa-check"></i></button><br>
        <button type ="reset" style="font-size:24px" name="reset"><i class="fa fa-close"></i></button><br>
        
       </form>
        </div>
      </div>


What I have tried:

I keep trying to fix it by googling and stackoverflow but don't seem to find any solution.
Posted
Updated 28-Mar-23 23:23pm
v2
Comments
Member 15627495 29-Mar-23 4:37am    
you have not any $_POST field which is named 'id'.
verify your form and input, search for the 'name=id' , or id='id' , you don't have one call 'id'.
=======================================================
when you check count($_POST) > 0 , be aware that cookie content belong to the sent 'String', so the 0 as value to check can be bypass when ever you have no datas sent,
use the 'dev tool' in your web browser, at the 'network' section to read all sent parameters.

1 solution

Read the error message carefully - it's telling you what you need to know.
As Member 15627495 has said - you don't have a POST field called "id" - so check your HTML and look at what it should be called.

You should expect to get syntax errors every day, probably many times a day while you are coding - we all do regardless of how much experience we have! Sometimes, we misspell a variable, or a keyword; sometimes we forget to close a string or a code block. Sometimes the cat walks over your keyboard and types something really weird. Sometimes we just forget how many parameters a method call needs.

We all make mistakes.

And because we all do it, we all have to fix syntax errors - and it's a lot quicker to learn how and fix them yourself than to wait for someone else to fix them for you! So invest a little time in learning how to read error messages, and how to interpret your code as written in the light of what the compiler is telling you is wrong - it really is trying to be helpful!

So read this: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] - it should help you next time you get a compilation error!

And spending a little time learning to understand syntax error messages will save you a huge amount of time in future: you waited at least 1/4 hour for any reply, then your email system probably added another 10 minutes or so, plus the time it took you to type up the question once you had found this site and created an account. Chances are that you could have saved a significant chunk of that time if you knew how to read them!

I'm not saying we don't want to help you fix them - sometimes I can't see my own errors because I read what I meant to write - but fixing syntax errors is part of the job, and if you can't do it for yourself people are going to look at you as a bit weird should you get a job in the industry!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900