0% found this document useful (0 votes)
1 views19 pages

Pdf24 Merged

The document contains various code snippets including HTML for a contact form, a responsive layout, PHP scripts for CRUD operations, and user information display. It showcases the use of CSS for styling and PHP for server-side logic. The examples demonstrate how to create interactive web applications with forms and database interactions.

Uploaded by

Taj Faizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views19 pages

Pdf24 Merged

The document contains various code snippets including HTML for a contact form, a responsive layout, PHP scripts for CRUD operations, and user information display. It showcases the use of CSS for styling and PHP for server-side logic. The examples demonstrate how to create interactive web applications with forms and database interactions.

Uploaded by

Taj Faizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

//CODE::

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Form</title>
<style>
body {
margin: 0;
padding: 0;
background: linear-gradient(to right, #6a11cb, #2575fc);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-
serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.contact-form {
background: #ffffff;
padding: 30px 35px;
border-radius: 15px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
max-width: 450px;
width: 100%;
}

.contact-form h2 {
text-align: center;
margin-bottom: 25px;
color: #333;
}

.contact-form input,
.contact-form textarea {
width: 100%;
padding: 12px 15px;
margin: 10px 0;
border: none;
border-radius: 8px;
background-color: #f0f0f0;
font-size: 15px;
transition: 0.3s;
}
.contact-form input:focus,
.contact-form textarea:focus {
outline: none;
background-color: #e6e6ff;
}

.contact-form button {
width: 100%;
padding: 12px;
background: linear-gradient(to right, #00c6ff, #0072ff);
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: 0.3s;
}

.contact-form button:hover {
background: linear-gradient(to right, #0072ff, #00c6ff);
}
</style>
</head>
<body>

<div class="contact-form">
<h2>Contact Us</h2>
<form>
<input type="text" name="name" placeholder="Your Name"
required>
<input type="email" name="email" placeholder="Your Email"
required>
<input type="text" name="address" placeholder="Your
Address" required>
<textarea name="message" rows="5" placeholder="Your
Message" required></textarea>
<button type="submit">Send Message</button>
</form>
</div>

</body>
</html>
//OUTPUT::
//CODE::

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-
scale=1.0"/>
<title>Responsive Layout</title>
<style>

* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
display: grid;
grid-template-areas:
"header"
"nav"
"main"
"aside"
"footer";
grid-template-columns: 1fr;
gap: 1rem;
padding: 1rem;
font-family: Arial, sans-serif;
}
header {
grid-area: header;
background-color: #4CAF50;
color: white;
padding: 1rem;
text-align: center;
}

nav {
grid-area: nav;
background-color: #f2f2f2;
padding: 1rem;
}
main {
grid-area: main;
background-color: #e0e0e0;
padding: 1rem;
}

aside {
grid-area: aside;
background-color: #d4d4d4;
padding: 1rem;
}

footer {
grid-area: footer;
background-color: #333;
color: white;
padding: 1rem;
text-align: center;
}
@media (min-width: 600px) {
body {
grid-template-areas:
"header header"
"nav nav"
"main aside"
"footer footer";
grid-template-columns: 2fr 1fr;
}
}
@media (min-width: 992px) {
body {
grid-template-areas:
"header header header"
"nav main aside"
"footer footer footer";
grid-template-columns: 1fr 2fr 1fr;
}
}
</style>
</head>

<body>
<header>
<h1>My Responsive Website</h1>
</header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<main>
<h2>Main Content</h2>
<p>This is the main section of the page. It adapts to screen
size using CSS media queries.</p>
</main>
<aside>
<h2>Sidebar</h2>
<p>Additional information goes here.</p>
</aside>
<footer>
<p>&copy; 2025 My Website</p>
</footer>
</body>
</html>

//OUTPUT::
PROGRAM::

<?php

$text = "Programming is powerful and precise.";

$charToCount = 'p';

$count = 0;

for ($i = 0; $i < strlen($text); $i++) {

if ($text[$i] === $charToCount) {

$count++;

echo "The character '$charToCount' appears $count times in the text.";

?>
OUTPUT::
//CODE::

<?php
// Connect to MySQL
$conn = new mysqli("localhost", "root", "", "test_db");

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// CREATE
if (isset($_POST['create'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$conn->query("INSERT INTO users (name, email) VALUES
('$name', '$email')");
}

// UPDATE
if (isset($_POST['update'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$conn->query("UPDATE users SET name='$name', email='$email'
WHERE id=$id");
}

// DELETE
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
$conn->query("DELETE FROM users WHERE id=$id");
}

// READ
$users = $conn->query("SELECT * FROM users");
?>

<h2>CRUD Operation in PHP</h2>

<!-- Form for Add/Update -->


<form method="post">
ID (for update only): <input type="text" name="id"><br>
Name: <input type="text" name="name" required><br>
Email: <input type="email" name="email" required><br>
<button name="create">Create</button>
<button name="update">Update</button>
</form>
<!-- Display Users -->
<h3>Users List</h3>
<table border="1" cellpadding="5">

<tr><th>ID</th><th>Name</th><th>Email</th><th>Action</th></tr>
<?php while ($row = $users->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= $row['name'] ?></td>
<td><?= $row['email'] ?></td>
<td>
<a href="?delete=<?= $row['id'] ?>"
onclick="return confirm('Delete this user?')">Delete</a>
</td>
</tr>
<?php endwhile; ?>
</table>
//OUTPUT::
PROGRAM::

<?php

$total = 0;

for ($i = 0; $i <= 30; $i++) {

$total += $i;

echo "The sum of all integers from 0 to 30 is: $total";

?>
OUTPUT::
PROGRAM::

<?php

$rows = 5;

for ($i = 1; $i <= $rows; $i++) {

for ($j = 1; $j <= $rows - $i; $j++) {

echo "&nbsp;&nbsp;";

for ($k = 1; $k <= (2 * $i - 1); $k++) {

echo "*";

echo "<br>";

?>
OUTPUT::
//CODE::

<!DOCTYPE html>
<html>
<head>
<title>User Information</title>
</head>
<body>

<h2>List of Users</h2>

<?php

$users = array(
array("name" => "Prajjwal Pande", "email" =>
"prajjwal@emailcom", "age" => 20),
array("name" => "Shrinivas Mundkar", "email" =>
"Shrinivas@emailom", "age" => 20),
array("name" => "Somesh Pawar", "email" =>
"Somesh@emailcom", "age" => 21)
);

foreach ($users as $user) {


echo "<strong>Name:</strong> " . $user['name'] . "<br>";
echo "<strong>Email:</strong> " . $user['email'] .
"<br>";
echo "<strong>Age:</strong> " . $user['age'] .
"<br><br>";
}
?>

</body>
</html>
//OUTPUT::

You might also like