Don't create so many aliases on your variables. There is no reason for it if you are not modifying their value. If 2 variables hold the same value, but have different name your code gets harder to understand.
Don't declare empty strings explicitly. Try out my nifty trick of using trim with null-coalesce operator*:
trim($_POST['fname'] ?? '');
It doesn't trigger a notice and also defaults to an empty string if the variable doesn't exist. Personally I don't agree here with @mickmackusa statements that your should callisset
beforetrim
, I see no benefit in doing so, and much more prefer defaulting it to a null or empty string.Use
isset
orempty
. There is no need to call them both. Try:if (!empty($_POST['id'])) {
Your
id
should be an integer so you should enforce that. A short way of doing so would be$id = (int) ($_POST['id'] ?? null);
, but keep in mind that your should do more data validation than this!Use an associative array for your validation errors. This makes the syntax simpler (see answer by @mickmackusa), and still allows you to separate the messages. An empty array is falsish value so you can just check
if(!$errors)
to see if the validations passed.
In your HTML form you can then check if the key exists and display the message. Here again you could use null-coalesce operator*:<?php echo $validation_errors['embg'] ?? '';?>
to get rid of the pesky notices, or you could redesign your HTML to display the<span>
only if the message exists.Close your mysqli statement in the same code block it was created or not at all, PHP will do it for you anyway. If the prepare call fails it will return FALSE and your can't call
FALSE->close()
. Close the statement only if prepare was successful.Exit with a header. Exit can take an argument in the form of a string and header returns nothing which makes it a perfect pair to put together:
exit(header('location: employees.php'));
. Saves you one line at least.No need for an else statement after the
exit
. Exit will terminate the script so else part will never be reached.You should close mysqli connection either in the same block of code it was created or not at all. When PHP script terminated it will close the connection for you automatically. If you really need to close it yourself don't put it inside an if statement.
The only statement in the else part is an if statement. Use
elseif
instead. In your case the statement can beif/elseif/else
instead ofif{if/else}
Don't count the number of fetched rows from SQL. There is hardly ever need for that. Assuming your
id
is a unique column the SELECT will fetch 1 row only or fail altogether. Replaceif($result->num_rows == 1){
withif ($result = $stmt->get_result()) {
. See mysqli_stmt::get_resultPrevent XSS! Never output raw data regardless of where it came from. Use
htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
on any data displayed into HTML. I have created a wrapper function to make it simpler to call this.HMTL select tag doesn't have
type
orvalue
attributes.
Don't create so many aliases on your variables. There is no reason for it if you are not modifying their value. If 2 variables hold the same value, but have different name your code gets harder to understand.
Don't declare empty strings explicitly. Try out my nifty trick of using trim with null-coalesce operator*:
trim($_POST['fname'] ?? '');
It doesn't trigger a notice and also defaults to an empty string if the variable doesn't exist. Personally I don't agree here with @mickmackusa statements that your should callisset
beforetrim
, I see no benefit in doing so, and much more prefer defaulting it to a null or empty string.Use
isset
orempty
. There is no need to call them both. Try:if (!empty($_POST['id'])) {
Your
id
should be an integer so you should enforce that. A short way of doing so would be$id = (int) ($_POST['id'] ?? null);
, but keep in mind that your should do more data validation than this!Use an associative array for your validation errors. This makes the syntax simpler (see answer by @mickmackusa), and still allows you to separate the messages. An empty array is falsish value so you can just check
if(!$errors)
to see if the validations passed.
In your HTML form you can then check if the key exists and display the message. Here again you could use null-coalesce operator*:<?php echo $validation_errors['embg'] ?? '';?>
to get rid of the pesky notices, or you could redesign your HTML to display the<span>
only if the message exists.Close your mysqli statement in the same code block it was created or not at all. If the prepare call fails it will return FALSE and your can't call
FALSE->close()
. Close the statement only if prepare was successful.Exit with a header. Exit can take an argument in the form of a string and header returns nothing which makes it a perfect pair to put together:
exit(header('location: employees.php'));
. Saves you one line at least.No need for an else statement after the
exit
. Exit will terminate the script so else part will never be reached.You should close mysqli connection either in the same block of code it was created or not at all. When PHP script terminated it will close the connection for you automatically. If you really need to close it yourself don't put it inside an if statement.
The only statement in the else part is an if statement. Use
elseif
instead. In your case the statement can beif/elseif/else
instead ofif{if/else}
Don't count the number of fetched rows from SQL. There is hardly ever need for that. Assuming your
id
is a unique column the SELECT will fetch 1 row only or fail altogether. Replaceif($result->num_rows == 1){
withif ($result = $stmt->get_result()) {
. See mysqli_stmt::get_resultPrevent XSS! Never output raw data regardless of where it came from. Use
htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
on any data displayed into HTML. I have created a wrapper function to make it simpler to call this.HMTL select tag doesn't have
type
orvalue
attributes.
Don't create so many aliases on your variables. There is no reason for it if you are not modifying their value. If 2 variables hold the same value, but have different name your code gets harder to understand.
Don't declare empty strings explicitly. Try out my nifty trick of using trim with null-coalesce operator*:
trim($_POST['fname'] ?? '');
It doesn't trigger a notice and also defaults to an empty string if the variable doesn't exist. Personally I don't agree here with @mickmackusa statements that your should callisset
beforetrim
, I see no benefit in doing so, and much more prefer defaulting it to a null or empty string.Use
isset
orempty
. There is no need to call them both. Try:if (!empty($_POST['id'])) {
Your
id
should be an integer so you should enforce that. A short way of doing so would be$id = (int) ($_POST['id'] ?? null);
, but keep in mind that your should do more data validation than this!Use an associative array for your validation errors. This makes the syntax simpler (see answer by @mickmackusa), and still allows you to separate the messages. An empty array is falsish value so you can just check
if(!$errors)
to see if the validations passed.
In your HTML form you can then check if the key exists and display the message. Here again you could use null-coalesce operator*:<?php echo $validation_errors['embg'] ?? '';?>
to get rid of the pesky notices, or you could redesign your HTML to display the<span>
only if the message exists.Close your mysqli statement in the same code block it was created or not at all, PHP will do it for you anyway. If the prepare call fails it will return FALSE and your can't call
FALSE->close()
. Close the statement only if prepare was successful.Exit with a header. Exit can take an argument in the form of a string and header returns nothing which makes it a perfect pair to put together:
exit(header('location: employees.php'));
. Saves you one line at least.No need for an else statement after the
exit
. Exit will terminate the script so else part will never be reached.You should close mysqli connection either in the same block of code it was created or not at all. When PHP script terminated it will close the connection for you automatically. If you really need to close it yourself don't put it inside an if statement.
The only statement in the else part is an if statement. Use
elseif
instead. In your case the statement can beif/elseif/else
instead ofif{if/else}
Prevent XSS! Never output raw data regardless of where it came from. Use
htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
on any data displayed into HTML. I have created a wrapper function to make it simpler to call this.HMTL select tag doesn't have
type
orvalue
attributes.
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
// $stmt->close(); // it's redundant in this context
}
}
} elseif ($id = (int)$_GET['id']) {
// Check existence of id parameter before processing further
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
if ($result = $stmt->get_result();
if ($result->num_rows) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
// $stmt->close(); // it's redundant in this context
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
// $mysqli->close(); // it's redundant in this context
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
// $stmt->close(); // it's redundant in this context
}
}
} elseif ($id = (int)$_GET['id']) {
// Check existence of id parameter before processing further
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
if ($result = $stmt->get_result()) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
// $stmt->close(); // it's redundant in this context
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
// $mysqli->close(); // it's redundant in this context
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
// $stmt->close(); // it's redundant in this context
}
}
} elseif ($id = (int)$_GET['id']) {
// Check existence of id parameter before processing further
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
$result = $stmt->get_result();
if ($result->num_rows) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
// $stmt->close(); // it's redundant in this context
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
// $mysqli->close(); // it's redundant in this context
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
// $stmt->close(); // it's redundant in this context
}
}
} elseif (!empty($id = (int)$_GET['id'])) {
// Check existence of id parameter before processing further
// Get URL parameter
$id = (int) ($_GET['id'] ?? null);
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
if ($result = $stmt->get_result()) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
// $stmt->close(); // it's redundant in this context
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
// $mysqli->close(); // it's redundant in this context
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
$stmt->close();
}
}
} elseif (!empty((int)$_GET['id'])) {
// Check existence of id parameter before processing further
// Get URL parameter
$id = (int) ($_GET['id'] ?? null);
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
if ($result = $stmt->get_result()) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
$stmt->close();
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
$mysqli->close();
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
// Include config file
require_once 'config.php';
// Processing form data when form is submitted
if (!empty($_POST['id'])) {
// Get hidden input value
$id = (int) ($_POST['id'] ?? null);
// define an empty array for validation errors to be displayed in HTML form
$validation_errors = [];
// Validate First Name ($fname)
$fname = trim($_POST['fname'] ?? '');
if (empty($fname)) {
$validation_errors['fname'] = 'Please enter your First Name.';
}
// Validate Last Name ($lname)
$lname = trim($_POST['lname'] ?? '');
if (empty($lname)) {
$validation_errors['lname'] = 'Please enter your Last Name.';
}
// Validate Date of Birth ($dob)
$dob = trim($_POST['dob'] ?? '');
if (empty($dob)) {
$validation_errors['dob'] = 'Please enter your Date of Birth.';
}
// Validate EMBG ($embg)
$embg = trim($_POST['embg'] ?? '');
if (empty($embg)) {
$validation_errors['embg'] = 'Please enter your EMBG.';
}
// Validate Address ($address)
$address = trim($_POST['address'] ?? '');
if (empty($address)) {
$validation_errors['address'] = 'Please enter an address.';
}
// Validate City ($city)
$city = trim($_POST['city'] ?? '');
if (empty($city)) {
$validation_errors['city'] = 'Please enter your City.';
}
// Validate Mobile Number ($mobile)
$mobile = trim($_POST['mobile'] ?? '');
if (empty($mobile)) {
$validation_errors['mobile'] = 'Please enter your Mobile.';
}
// Validate E-mail ($email)
$email = trim($_POST['email'] ?? '');
if (empty($email)) {
$validation_errors['email'] = 'Please enter your E-mail.';
}
// Validate WorkPlace ($workplace)
$workplace = trim($_POST['workplace'] ?? '');
if (empty($workplace)) {
$validation_errors['workplace'] = 'Please choose your Work Place.';
}
// Validate Work Position ($workposition)
$workposition = trim($_POST['workposition'] ?? '');
if (empty($workposition)) {
$validation_errors['workposition'] = 'Please choose your Work Position.';
}
// Validate Job Start Date ($jobstartdate)
$jobstartdate = trim($_POST['jobstartdate'] ?? '');
if (empty($jobstartdate)) {
$validation_errors['jobstartdate'] = 'Please enter your Date of Birth.';
}
// Validate Contract From ($contractfrom)
$contractfrom = trim($_POST['contractfrom'] ?? '');
if (empty($contractfrom)) {
$validation_errors['contractfrom'] = 'Please enter your Date of Birth.';
}
// Check input errors before inserting in database jobstartdate
if (!$validation_errors) {
// Prepare an update statement
$sql = 'UPDATE addemployees SET fname=?, lname=?, dob=?, embg=?, address=?, city=?, mobile=?, email=?, workplace=?,
workposition=?, jobstartdate=?, contractfrom=? WHERE id=?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param(
'ssssssssssssi',
$fname,
$lname,
$dob,
$embg,
$address,
$city,
$mobile,
$email,
$workplace,
$workposition,
$jobstartdate,
$contractfrom,
$id
);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
// Records updated successfully. Redirect to landing page
exit(header('location: employees.php')); // exit with a header
}
echo 'Something went wrong. Please try again later.';
// Close statement
// $stmt->close(); // it's redundant in this context
}
}
} elseif ($id = (int)$_GET['id']) {
// Check existence of id parameter before processing further
// Prepare a select statement
$sql = 'SELECT * FROM addemployees WHERE id = ?';
if ($stmt = $mysqli->prepare($sql)) {
// Bind variables to the prepared statement as parameters
$stmt->bind_param('i', $id);
// Attempt to execute the prepared statement
if ($stmt->execute()) {
if ($result = $stmt->get_result()) {
// Fetch result row as an associative array. Since the result set contains only one row, we don't need to use while loop
$row = $result->fetch_array(MYSQLI_ASSOC);
// Retrieve individual field value
$fname = $row['fname'];
$lname = $row['lname'];
$dob = $row['dob'];
$embg = $row['embg'];
$address = $row['address'];
$city = $row['city'];
$mobile = $row['mobile'];
$email = $row['email'];
$workplace = $row['workplace'];
$workposition = $row['workposition'];
$jobstartdate = $row['jobstartdate'];
$contractfrom = $row['contractfrom'];
} else {
// URL doesn't contain valid id. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
} else {
echo 'Oops! Something went wrong. Please try again later.';
}
// Close statement
// $stmt->close(); // it's redundant in this context
}
} else {
// URL doesn't contain id parameter. Redirect to error page
exit(header('location: error.php')); // exit with a header
}
// Close connection
// $mysqli->close(); // it's redundant in this context
function clean_HTML(string $str): string
{
return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Record</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<style type="text/css">
.wrapper{
width: 500px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h2>Измени Податоци</h2>
</div>
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
<div class="form-group <?php echo isset($validation_errors['fname']) ? 'has-error' : ''; ?>">
<label>Име</label>
<input type="text" id="fname" name="fname" class="form-control" value="<?php echo clean_HTML($fname); ?>">
<span class="help-block"><?php echo $validation_errors['fname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['lname']) ? 'has-error' : ''; ?>">
<label>Презиме</label>
<input type="text" name="lname" id="lname" class="form-control" value="<?php echo clean_HTML($lname); ?>">
<span class="help-block"><?php echo $validation_errors['lname'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['dob']) ? 'has-error' : ''; ?>">
<label>Дата на Раѓање</label>
<input type="date" name="dob" id="dob" class="form-control" value="<?php echo clean_HTML($dob); ?>">
<span class="help-block"><?php echo $validation_errors['dob'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['embg']) ? 'has-error' : ''; ?>">
<label>ЕМБГ</label>
<input type="text" name="embg" id="embg" class="form-control" maxlength="13" value="<?php echo clean_HTML($embg); ?>">
<span class="help-block"><?php echo $validation_errors['embg'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['address']) ? 'has-error' : ''; ?>">
<label>Адреса</label>
<input type="text" id="address" name="address" class="form-control" value="<?php echo clean_HTML($address); ?>">
<span class="help-block"><?php echo $validation_errors['address'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['city']) ? 'has-error' : ''; ?>">
<label>Град</label>
<input type="text" name="city" id="city" class="form-control" value="<?php echo clean_HTML($city); ?>">
<span class="help-block"><?php echo $validation_errors['city'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['mobile']) ? 'has-error' : ''; ?>">
<label>Мобилен</label>
<input type="text" name="mobile" id="mobile" class="form-control" maxlength="9" value="<?php echo clean_HTML($mobile); ?>">
<span class="help-block"><?php echo $validation_errors['mobile'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['email']) ? 'has-error' : ''; ?>">
<label>Е-маил</label>
<input type="text" name="email" id="email" class="form-control" value="<?php echo clean_HTML($email); ?>">
<span class="help-block"><?php echo $validation_errors['email'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workplace']) ? 'has-error' : ''; ?>">
<label>Работно Место <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workplace" id="workplace" class="form-control" >
<option value="Кафич ГТ-1 - Широк Сокак бр. 55">Кафич ГТ-1 - Широк Сокак бр. 55</option>
<option value="Кафич ГТ-2 - Широк Сокак бр. 94">Кафич ГТ-2 - Широк Сокак бр. 94</option>
<option value="Ланч Бар ГТ - Широк Сокак бр. 55">Ланч Бар ГТ - Широк Сокак бр. 55</option>
<option value="Главен Магацин - Боримечка">Главен Магацин - Боримечка</option>
</select>
<span class="help-block"><?php echo $validation_errors['workplace'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['workposition']) ? 'has-error' : ''; ?>">
<label>Работна Позиција <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(ПРОВЕРИ)</span></label>
<select name="workposition" id="workposition" class="form-control" >
<option value="Келнер">Келнер</option>
<option value="Шанкер">Шанкер</option>
<option value="Колачи">Колачи</option>
<option value="Сладолед">Сладолед</option>
<option value="Производство Сладолед">Производство Сладолед</option>
<option value="Производство Торти">Производство Торти</option>
<option value="Кувар">Кувар</option>
<option value="Помошник Кувар">Помошник Кувар</option>
<option value="Салатер">Салатер</option>
<option value="Пицер">Пицер</option>
<option value="Менаџер">Менаџер</option>
<option value="Книговодител">Книговодител</option>
<option value="Хигиеничар">Хигиеничар</option>
<option value="Стражар">Стражар</option>
<option value="Магационер">Магационер</option>
<option value="Шофер">Шофер</option>
<option value="Дистрибутер">Дистрибутер</option>
</select>
<span class="help-block"><?php echo $validation_errors['workposition'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['jobstartdate']) ? 'has-error' : ''; ?>">
<label>Дата на Почнување на Работа <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="jobstartdate" id="jobstartdate" class="form-control" value="<?php echo clean_HTML($jobstartdate); ?>">
<span class="help-block"><?php echo $validation_errors['jobstartdate'] ?? '';?></span>
</div>
<div class="form-group <?php echo isset($validation_errors['contractfrom']) ? 'has-error' : ''; ?>">
<label>Договор за работа од <span style="font-size: 15px; color: rgb(255, 0, 0); margin-right: 15px;">(Месец/Ден/Година)</span></label>
<input type="date" name="contractfrom" id="contractfrom" class="form-control" value="<?php echo clean_HTML($contractfrom); ?>">
<span class="help-block"><?php echo $validation_errors['contractfrom'] ?? '';?></span>
</div>
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<input type="submit" class="btn btn-primary" value="Submit">
<a href="employees.php" class="btn btn-default">Cancel</a>
</form>
</div>
</div>
</div>
</div>
</body>
</html>