Professional Documents
Culture Documents
Design a form for the Patient Satisfaction Survey for a particular hospital having the following fields:
• Patient's name
• Patient's File number (Issued by the hospital)
• Which Unit of the hospital the patient was admitted Select V (Surgery, Medicine, etc.)
• Are you satisfied with overall treatment : Very Satisfied Satisfied Not Satisfied
• Are you satisfied with medical facilities in the hospital : Very Satisfied Satisfied Not Satisfied
• Overall Comments 15
Submit
Reset
** CODE **
<?php
// Initialize variables for error handling
$nameErr = $fileNumberErr = $unitErr = $treatmentSatisfactionErr = $facilitiesSatisfactionErr = "";
$successMessage = false;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Validate and sanitize input
$name = test_input($_POST["name"]);
$fileNumber = test_input($_POST["fileNumber"]);
$unit = test_input($_POST["unit"]);
$treatmentSatisfaction = test_input($_POST["treatmentSatisfaction"]);
$facilitiesSatisfaction = test_input($_POST["facilitiesSatisfaction"]);
$comments = test_input($_POST["comments"]);
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Patient Satisfaction Survey</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f7f7f7;
}
h1 {
text-align: center;
color: #333;
}
.message {
max-width: 500px;
margin: 0 auto;
background-color: #D4ADFC;
margin-bottom : 10px;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.message p{
color : #000;
}
.container {
max-width: 500px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
margin-bottom : 10px;
}
label {
display: block;
font-weight: bold;
margin-top: 10px;
}
input[type="text"],
select,
textarea {
width: 100%;
padding: 10px;
margin-top: 5px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="radio"] {
margin-right: 5px;
}
.error {
color: #ff0000;
font-size: 14px;
}
.submit-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.reset-button {
background-color: #f44336;
color: white;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Patient Satisfaction Survey</h1>
<?php if (isset($successMessage) && !empty($successMessage)) { ?>
<div class="message">
<p><?php echo $successMessage; ?></p>
</div>
<?php } ?>
<div class="container">
** CODE **
<!DOCTYPE html>
<html>
<head>
<title>Cookies Example</title>
</head>
<body>
<h1>Cookie Management</h1>
<p id="cookieDisplay"></p>
<script>
function setCookie(cookieName) {
var cookieValue = prompt('Enter the value for ' + cookieName + ':');
document.cookie = cookieName + '=' + cookieValue;
}
function getCookie(cookieName) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.startsWith(cookieName + '=')) {
var cookieValue = cookie.substring(cookieName.length + 1);
alert(cookieName + ' = ' + cookieValue);
return;
}
}
alert(cookieName + ' not found');
}
function deleteCookie(cookieName) {
document.cookie = cookieName + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC;';
alert(cookieName + ' deleted');
}
function displayAllCookies() {
var cookies = document.cookie.split(';');
var cookieDisplayText = 'All Cookies:' + '\n';
for (var i = 0; i < cookies.length; i++) {
cookieDisplayText += cookies[i].trim() + '\n';
}
document.getElementById('cookieDisplay').textContent = cookieDisplayText;
}
</script>
</body>
</html>
** OUTPUT **
- Set Cookies
- Stored Cookies
- Get Cookies
- Deleting Cookies