I fill the in form and get: Parse error: syntax error, unexpected '=' on line 12
and if a field is empty, it doesn't show
---------------------------------------------------------
the code:
<?php
include_once("config.php");
if(isset($_POST['update']))
{
$id = mysqli_real_escape_string($mysqli, $_POST['id']);
$unit = mysqli_real_escape_string($mysqli, $_POST['unit']);
$tenant = mysqli_real_escape_string($mysqli, $_POST['tenant']);
$effectdate = mysqli_real_escape_string($mysqli, $_POST['effectdate']);
$expdate = mysqli_real_escape_string($mysqli, $_POST['expdate']);
$moveindate = mysqli_real_escape_string($mysqli, $_POST['moveindate']);
removaldate = mysqli_real_escape_string($mysqli, $_POST['removaldate']);
daysleft = mysqli_real_escape_string($mysqli, $_POST['daysleft']); // ** line 12
date90 = mysqli_real_escape_string($mysqli, $_POST['date90']);
date60 = mysqli_real_escape_string($mysqli, $_POST['date60']);
date30 = mysqli_real_escape_string($mysqli, $_POST['date30']);
if(empty($unit) || empty($tenant) || empty($effectdate) || empty($expdate)
|| empty($moveindate) || empty($removaldate) || empty($daysleft)
|| empty($date90) || empty($date60) || empty($date30)) {
if(empty($unit)) { echo '<font color="red">unit field is empty.</font><br>'; }
if(empty($tenant)) { echo '<font color="red">tenant field is empty.</font><br>'; }
if(empty($effectdate)) { echo '<font color="red">effectdate field is empty.</font><br>'; }
if(empty($expdate)) { echo '<font color="red">expdate field is empty.</font><br>'; }
if(empty($moveindate)) { echo '<font color="red">moveindate field is empty.</font><br>'; } // 35
if(empty(removaldate)) { echo '<font color="red">removaldate field is empty.</font><br>'; }
if(empty($daysleft)) { echo '<font color="red">daysleft field is empty.</font><br>'; }
if(empty($date90)) { echo '<font color="red">date90 field is empty.</font><br>'; }
if(empty($date60)) { echo '<font color="red">date60 field is empty.</font><br>'; }
if(empty($date30)) { echo '<font color="red">date30 field is empty.</font><br>'; }
} else {
$result = mysqli_query($mysqli, "UPDATE certtbl SET
unit='$unit',tenant='$tenant',effectdate='$effectdate',expdate='$expdate',moveindate='$moveindate',
removaldate='$removaldate',daysleft='$daysleft',date90='$date90',
date60='$date60',date30='$date30'
WHERE id=$id");
header("Location: certup.php");
}
}
and if a field is empty, it doesn't show
---------------------------------------------------------
the code:
<?php
include_once("config.php");
if(isset($_POST['update']))
{
$id = mysqli_real_escape_string($mysqli, $_POST['id']);
$unit = mysqli_real_escape_string($mysqli, $_POST['unit']);
$tenant = mysqli_real_escape_string($mysqli, $_POST['tenant']);
$effectdate = mysqli_real_escape_string($mysqli, $_POST['effectdate']);
$expdate = mysqli_real_escape_string($mysqli, $_POST['expdate']);
$moveindate = mysqli_real_escape_string($mysqli, $_POST['moveindate']);
removaldate = mysqli_real_escape_string($mysqli, $_POST['removaldate']);
daysleft = mysqli_real_escape_string($mysqli, $_POST['daysleft']); // ** line 12
date90 = mysqli_real_escape_string($mysqli, $_POST['date90']);
date60 = mysqli_real_escape_string($mysqli, $_POST['date60']);
date30 = mysqli_real_escape_string($mysqli, $_POST['date30']);
if(empty($unit) || empty($tenant) || empty($effectdate) || empty($expdate)
|| empty($moveindate) || empty($removaldate) || empty($daysleft)
|| empty($date90) || empty($date60) || empty($date30)) {
if(empty($unit)) { echo '<font color="red">unit field is empty.</font><br>'; }
if(empty($tenant)) { echo '<font color="red">tenant field is empty.</font><br>'; }
if(empty($effectdate)) { echo '<font color="red">effectdate field is empty.</font><br>'; }
if(empty($expdate)) { echo '<font color="red">expdate field is empty.</font><br>'; }
if(empty($moveindate)) { echo '<font color="red">moveindate field is empty.</font><br>'; } // 35
if(empty(removaldate)) { echo '<font color="red">removaldate field is empty.</font><br>'; }
if(empty($daysleft)) { echo '<font color="red">daysleft field is empty.</font><br>'; }
if(empty($date90)) { echo '<font color="red">date90 field is empty.</font><br>'; }
if(empty($date60)) { echo '<font color="red">date60 field is empty.</font><br>'; }
if(empty($date30)) { echo '<font color="red">date30 field is empty.</font><br>'; }
} else {
$result = mysqli_query($mysqli, "UPDATE certtbl SET
unit='$unit',tenant='$tenant',effectdate='$effectdate',expdate='$expdate',moveindate='$moveindate',
removaldate='$removaldate',daysleft='$daysleft',date90='$date90',
date60='$date60',date30='$date30'
WHERE id=$id");
header("Location: certup.php");
}
}