Web Tech File
Web Tech File
<h2>REGISTRATION FORM</h2>
<div class="my-div">
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name" required><br>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
<label for="country">Country:</label><br>
<input type="text" id="country" name="country" required><br>
<label for="city">City:</label><br>
<input type="text" id="city" name="city" required><br>
<label for="gender">Gender:</label><br>
<div class="radio-container">
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
</div>
</form>
</div>
</body>
</html>
CSS code :
3
.radio-container {
background-color: #36454F;
display: flex;
align-items: center;
margin-bottom: 20px;
Page |4
.radio-container label {
margin-right: 10px;
}
OUTPUT:
<html lang="en">
<head>
<title>List Example</title>
</head>
<body>
<h1>Types of Fruits</h1>
OUTPUT:
Page |6
<h2>Lists</h2>
<ul>
<li>This is an unordered list item 1</li>
<li>This is an unordered list item 2</li>
<li>This is an unordered list item 3</li>
</ul>
<ol>
<li>This is an ordered list item 1</li>
<li>This is an ordered list item 2</li>
<li>This is an ordered list item 3</li>
</ol>
<h2>Links</h2>
<p>Visit <a href="https://www.example.com">Example.com</a> for more
information.</p>
<h2>Images</h2>
<img src="https://www.example.com/image.jpg" alt="Example Image">
<h2>Blockquotes</h2>
<blockquote>
This is a blockquote. It is often used to highlight a quote from another source.
</blockquote>
<h2>Code</h2>
<pre>
<code>
function greet() {
console.log("Hello, world!");
}
</code>
</pre>
Page |8
</body>
</html>
OUTPUT:
<!DOCTYPE html>
<html>
<head>
<title>Style Example</title>
<style>
body {
Page |9
OUTPUT:
P a g e | 10
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<style>
.error {
color: red;
}
</style>
</head>
<body>
<h1>Registration Form</h1>
<form id="registrationForm" onsubmit="return validateForm()">
<label for="name">Name:</label>
P a g e | 11
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<span class="error" id="emailError"></span><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<span class="error" id="passwordError"></span><br><br>
<script>
function validateForm() {
const name = document.getElementById("name").value;
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
// Validate Name
if (name === "") {
document.getElementById("nameError").innerHTML = "Name is required";
isValid = false;
}
// Validate Email
if (email === "") {
document.getElementById("emailError").innerHTML = "Email is required";
isValid = false;
} else if (!isValidEmail(email)) {
document.getElementById("emailError").innerHTML = "Invalid email format";
isValid = false;
P a g e | 12
// Validate Password
if (password === "") {
document.getElementById("passwordError").innerHTML = "Password is
required";
isValid = false;
} else if (password.length < 8) {
document.getElementById("passwordError").innerHTML = "Password must be
at least 8 characters";
isValid = false;
}
return isValid;
}
function isValidEmail(email) {
const emailRegex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailRegex.test(email);
}
</script>
</body>
</html>
OUTPUT:
P a g e | 13
<!DOCTYPE html>
<html>
<head>
<title>Disable Buttons Example</title>
<script>
function disableButtons() {
var buttons = document.getElementsByTagName("button");
setTimeout(disableButtons, 5000);
</script>
<style>
body{
background-color: #36454F;
color: white;
}
</style>
</head>
<body>
<h1>Disable Button Example</h1>
<button>Button 1</button>
</body>
</html>
OUTPUT:
P a g e | 15
<!DOCTYPE html>
<html>
<head>
<title>Prime Number Checker</title>
<script>
function isPrime()
{
var number = parseInt(document.getElementById("number").value);
if (number < 2)
{
document.getElementById("result").innerHTML = "Not a prime number";
return;
}
P a g e | 16
if (number % i === 0)
{
document.getElementById("result").innerHTML = "Not a prime number";
return;
}
}
<!DOCTYPE html>
<html>
<head>
<title>Sum of Three Numbers</title>
<script>
// Function to calculate the sum of three numbers
function sumOfThreeNumbers() {
// Get the input values
var number1 = parseInt(document.getElementById("number1").value);
var number2 = parseInt(document.getElementById("number2").value);
var number3 = parseInt(document.getElementById("number3").value);
OUTPUT:
P a g e | 19
<?php
$file = "helloworld.txt";
OUTPUT:
<?php
$file = "file.txt";
$data = "Hi how are you?";
fclose($handle);
?>
OUTPUT:
<?php
$file = "example.txt";
OUTPUT:
P a g e | 22
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$targetDir = "uploads/"; // Directory where the uploaded files will be stored
$targetFile = $targetDir . basename($_FILES["fileToUpload"]["name"]); // Path
of the uploaded file
if (file_exists($targetFile)) {
echo "File already exists.";
exit;
}
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<h2>Upload a File</h2>
<form method="POST" action="<?php echo
htmlspecialchars($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
<input type="file" name="fileToUpload" required><br><br>
<input type="submit" value="Upload">
</form>
</body>
</html>
OUTPUT:
P a g e | 24
<?php
session_start();
?>
<html>
<head>
<title>session 1</title>
<body>
<?php
$_SESSION['name']="SESSION 1";
$_SESSION['id']=785;
echo "Sessions are working";
?>
</body>
</html>
P a g e | 25
OUTPUT: