0% found this document useful (0 votes)
31 views

php word file keval zerox

The document contains PHP code examples for creating a login page, registration page, file upload functionality, and basic CRUD operations (insert, update, delete, view) in MySQL. It also includes Python integration with PHP and a simple Flask application to print a name in the browser. Each section provides code snippets along with explanations and expected outputs.

Uploaded by

gulshanj353
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

php word file keval zerox

The document contains PHP code examples for creating a login page, registration page, file upload functionality, and basic CRUD operations (insert, update, delete, view) in MySQL. It also includes Python integration with PHP and a simple Flask application to print a name in the browser. Each section provides code snippets along with explanations and expected outputs.

Uploaded by

gulshanj353
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.

Y- 2024-2025)

1. Write a php code to perform login page with database connection.

<?php

include("connection.php");

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>

<div id="form">

<h1>Login Form</h1>

<form name="form" action="login.php" onsubmit="return isvalid()" method="POST">

<label>Username:</label>

<input type="text" id="user" name="user"></br></br>

<label>Password</label>

<input type="password"id="pass" name="pass"></br></br>

<input type="submit" id="btn" value="Login" name="submit"/>

</form>

</div>

<script>

function isvalid(){

var user = document.form.user.value;

var pass = document.form.pass.value;

if(user.length=="" && pass.length==""){

alert("Username and Password field is empty!!!");

Roll no. Page no.1


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

return false

else{

if(user.length==""){

alert("Username is empty!!!");

return false

if(pass.length==""){

alert("Password is empty!!!");

return false

} }

</script>

</body>

</html>

Style.css

body{

background-color: blueviolet;

#form{

background-color: white;

width: 25%;

margin: 120px auto;

padding: 50px;

box-shadow: 10px 10px 5px

rgb(82,11,77); border-radius: 6px;

#btn{

color: white;

background-color: rgb(106, 11, 194);

Roll no. Page no.2


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

padding: 10px;

font-size: large;

border-radius: 10px;

@media screen and (max-width:700px)

#form{

width: 65px;

padding: 40;

Connection.php

<?php

$servername = "localhost";

$username="root";

$password="";

$db_name="database1";

$conn = new mysqli($servername, $username, $password,

$db_name); if($conn->connect_error){

die("connection failed".$conn->connect_error);

echo "";

?>

Login.php

<?php

include("connection.php");

Roll no. Page no.3


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

if(isset($_POST['submit'])){

$username = $_POST['user'];

$password = $_POST['pass'];

$sql = "select * from login where username ='$username' and password='$password'";

$result = mysqli_query($conn, $sql);

$row = mysqli_fetch_array($result, MYSQLI_ASSOC);

$count = mysqli_num_rows($result);

if($count==1)

header("Location:welcome.php");

else{

echo '<script>

window.location.href = "index.php";

alert("Login failed. Invalid username or password!!!")

</script>';

?>

Roll no. Page no.4


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

OUTPUT:

Roll no. Page no.5


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

2. Write a php code to perform registration page with php and submit data in

mysql. Form.php

<?php

// Enable error reporting

error_reporting(E_ALL);

ini_set('display_errors', 1);

// Database connection details

$servername = "localhost";

$username = "root";

$password = "";

$dbname = "registration_db";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

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

// Check if the form is submitted

if ($_SERVER["REQUEST_METHOD"] == "POST") {

// Retrieve form data

$firstName = $_POST['firstName'];

$lastName = $_POST['lastName'];

$email = $_POST['email'];

$birthDate = $_POST['birthDate'];

$gender = $_POST['gender'];

Roll no. Page no.6


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

// Prepare and bind

$stmt = $conn->prepare("INSERT INTO users (firstName, lastName, email, birthDate, gender)


VALUES (?, ?, ?, ?, ?)");

$stmt->bind_param("sssss", $firstName, $lastName, $email, $birthDate, $gender);

// Execute the statement

if ($stmt->execute()) {

echo "New record created successfully";

} else {

echo "Error: " . $stmt->error;

// Close the statement

$stmt->close();

// Close the connection

$conn->close();

?>

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Registration Form</title>

<style>

body {

font-family: Arial, sans-

serif; background-color:

#f4f4f4; padding: 20px;

Roll no. Page no.7


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

.container {

max-width: 500px;

margin: 0 auto;

background-color: #fff;

padding: 20px;

border-radius: 10px;

box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);

h2 {

text-align: center;

input[type="text"], input[type="email"], input[type="date"] {

width: 100%;

padding: 10px;

margin: 5px 0;

border: 1px solid

#ccc; border-radius:

5px;

input[type="submit"] {

background-color:

#28a745; color: white;

padding: 10px;

border: none;

border-radius:

5px; cursor:

pointer;

width: 100%;
}

input[type="submit"]:hover {

background-color:
Roll no. Page no.8
SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

#218838;

Roll no. Page no.9


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

</style>

</head>

<body>

<div class="container">

<h2>Registration Form</h2>

<form method="POST" action="">

<label for="firstName">First Name:</label>

<input type="text" id="firstName" name="firstName" required>

<label for="lastName">Last Name:</label>

<input type="text" id="lastName" name="lastName" required>

<label for="email">Email:</label>

<input type="email" id="email" name="email" required>

<label for="birthDate">Birth Date:</label>

<input type="date" id="birthDate" name="birthDate" required>

<label for="gender">Gender:</label>

<input type="text" id="gender" name="gender" required>

<input type="submit" value="Register">

</form>

</div>

</body>

</html>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

3. Write a php code to upload file(pdf,jpeg,jpg,png,etc).

<html>

<head></head>

<body>

<form method='post' enctype='multipart/form-data' action='receive.php'>

<input type='file' name='myfile'/>

<input type='submit' name='upload' value='SEND'/>

</form>

</body>

</html>

Receive.php

<?php

$name=$_FILES['myfile']['name'];

$tmp_name=$_FILES['myfile']['tmp_name'];

if(move_uploaded_file($tmp_name,$name))

echo"File uploaded";

else

echo"file not uploaded";

?>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

4. Write a php code to perform following task:


1) insert data in mysql.
<!DOCTYPE html>
<html>
<head>
<title>insert</title>
</head>
<body>
<div class="row text-center">
<div class="container">
<h1>Insert DATA</h1>
<form action="index.php" method="post">
<input type="text" name="firstname" placeholder="firstname"><br><br>
<input type="text" name="lastname" placeholder="lastname"><br><br>
<input type="gmail" name="gmail" placeholder="gmail"><br><br>
<input type="text" name="number" placeholder="number"><br><br>
<input type="text" name="address" placeholder="address"><br><br>
<input type="submit" name="submit" value="insert"><br><br>
</form>
<button><a href="show.php">show data</a></button>
</div>
</div>
</body>
</html>
<?php
error_reporting(0);
include 'connection.php';
if (isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$gmail = $_POST['gmail'];

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

$number = $_POST['number'];
$address = $_POST['address'];
$sql = "INSERT INTO `reg` VALUES
('$id','$firstname','$lastname','$gmail','$number','$address')";
$data=mysqli_query($con,$sql);
if ($data) {
echo "insert";
}
else
{

echo "sorry";
}
}
?>
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

2) update data in mysql.


<!DOCTYPE html>
<html>
<head>
<title>update</title>
</head>
<body>
<form action="" method="get">
<input type="text" name="id" placeholder="id" value="<?php echo $_GET['id'];
?>"><br><br>
<input type="text" name="firstname" placeholder="firstname" value="<?php echo
$_GET['firstname']; ?>"><br><br>
<input type="text" name="lastname" placeholder="lastname" value="<?php echo
$_GET['lastname']; ?>" ><br><br>
<input type="gmail" name="gmail" placeholder="gmail" value="<?php echo
$_GET['gmail']; ?>"><br><br>
<input type="text" name="number" placeholder="number" value="<?php echo
$_GET['number']; ?>"><br><br>
<input type="text" name="address" placeholder="address" value="<?php echo
$_GET['address']; ?>"><br><br>
<input type="submit" name="submit" value="update">
</form>
<?php
error_reporting(0);
include ('connection.php');
if ($_GET['submit'])
{
$id = $_GET['id'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$gmail = $_GET['gmail'];
$number = $_GET['number'];

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

$address = $_GET['address'];
$sql="UPDATE reg SET firstname='$firstname' , lastname='$lastname',
gmail='$gmail' , number='$number', address='$address' WHERE id='$id'";
$data=mysqli_query($con, $sql);
if ($data) {
//echo "record update";
header('location:show.php');
}
else{
echo "not update";
}
}
else
{
echo "click on button to save the change";
}
?>
</body>
</html>
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

3) delete data in mysql.


<?php
include ('connection.php');
$id = $_GET['id'];
$sql ="DELETE FROM `reg` WHERE id='$id'";
$data = mysqli_query($con,$sql);
if ($data) {
echo "deleted";
header('location:show.php');
}else
{
echo "error";
}
?>
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

4) view data in mysql.


<!DOCTYPE html>
<html>
<head>
<title>show table</title>
</head>
<body>
<?php
include ('connection.php');
$sql ="select * from reg";
$data =mysqli_query($con,$sql);
$total=mysqli_num_rows($data);
if ($total=mysqli_num_rows($data)) {
?>
<table border="2">
<tr>
<th>id</th>
<th>firstname</th>
<th>lastname</th>
<th>gmail</th>
<th>number</th>
<th>address</th>
<th>delete</th>
<th>update</th>
</tr>
<?php
while ($result = mysqli_fetch_array($data)) {
echo "
<tr>
<td>".$result['id']."</td>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

<td>".$result['firstname']."</td>
<td>".$result['lastname']."</td>
<td>".$result['gmail']."</td>
<td>".$result['number']."</td>
<td>".$result['address']."</td>
<td><a href='update.php?id=$result[id] &
firstname=$result[firstname] & lastname=$result[lastname] & gmail=$result[gmail] &
number=$result[number] &address=$result[address]'> update </a></td>
<td><a href='delete.php?id=$result[id] '>delete </a></td>
</tr>
";
}
}
else
{
echo "no record found";
}
?>
</table>
</body>
</html>
<!--------- echo "<br>".$result['id']." ".$result['firstname']." ".$result['lastname']."
".$result['gmail']." ".$result['number']." ".$result['address']."<br>";_----->
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

5. Write a php code with Python Integration (print your name in prompt).
Test.py
import requests
value_to_pass = "Hello, My Name is keval."
php_url = "http://localhost/anaconda/hello.php"
params = {"value": value_to_pass}
response = requests.get(php_url, params=params)
print("Output from PHP script:")
print(response.text)
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

6. Print your name on browser using


flask. h.py
from flask import Flask
app = Flask( name )
@app.route('/')
def print_name():
return "Hello, keval
Here!" if name == "
main ":
app.run(debug=True)
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

7. Write a python program to open multiple pages.


App.py
from flask import Flask, render_template

app = Flask( name )

# Route for the home page


@app.route("/")
def home():
return "Welcome to the Home Page!"

# Route for the 'about' page


@app.route("/about")
def about():
return "This is the About Page!"

# Route for the 'contact' page


@app.route("/contact")
def contact():
return "This is the Contact Page!"

# Route for the 'services' page


@app.route("/services")
def services():
return "This is the Services Page!"

# Route for the 'products' page


@app.route("/products")
def products():
return "This is the Products Page!"

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

# Main function to run the Flask


app if name == " main ":
app.run(debug=True)
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

8. write a php code with python integration to perform following task:


a) Heading (Shrinathji College)
b) Write minimum 10 line in Paragraph
c) Give appropriate
design using template.
mai.py
from flask import Flask, render_template
app = Flask( name )
@app.route('/')
def heading():
return
render_template('heading.php') if
name == ' main ':
app.run(debug=True)
heading.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shrinathji College</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#f4f4f9; margin: 0;
padding: 0;
}
.container {
width: 80%;
margin: auto;
Roll no. Page
SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

overflow: hidden;
}
header {
background:
black; color: #fff;
padding-top: 30px;
min-height: 70px;
border-bottom: #ff6347 3px solid;
}
header h1 {
text-align: center;
text-transform: uppercase;
margin: 0;
font-size: 36px;
letter-spacing:
2px;
}
p{
font-size: 18px;
line-height: 1.6;
color: #333;
}
.content {
background: #fff;
padding: 20px;
margin-top: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

<header>
<h1>Shrinathji College</h1>
</header>

<div class="container">
<div class="content">
<p>
Shrinathji College is a renowned institution known for its commitment to
quality education.
The college offers a wide range of programs that cater to the diverse
academic interests of students.
With a strong faculty team and excellent infrastructure, the college creates
an environment conducive to learning.
Students are encouraged to explore their interests and develop critical
thinking skills.
In addition to academics, the college places a strong emphasis
on
extracurricular activities.
This holistic approach ensures that students grow both personally and
professionally.
Shrinathji College fosters an inclusive and collaborative environment for
students from all walks of life.
The institution prides itself on its modern facilities and up-to-date
curriculum.
Graduates from the college are equipped to face the challenges of the
modern world with confidence.
As a hub of innovation, Shrinathji College is constantly evolving to meet
the needs of its students.
</p>

</div>
</div>
</body>
</html>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

9. Write a python flask program to open html and css file from template
folder. index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website</title>
<style>
{{ styles | safe }}
</style>
</head>
<body>
<h1>This is my website</h1>
<p>Hello, my name is sagar, and I will be running this Python program to open the
html and css file </p>
</body>
</html>
styles.css
body {
font-family: Arial, sans-
serif; background-color:
#f0f0f0; margin: 0;
padding: 20px;
}

h1 {
background-color: orangered;
color: white; /* Optional: change text color for contrast */
padding: 10px; /* Optional: add some padding */
}

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

p{
color: #555555;
}
app.py
from flask import Flask, render_template
import os

app = Flask( name )

@app.route('/')
def home():
with open(os.path.join(app.template_folder, 'styles.css')) as f:
styles = f.read()
return render_template('index.html', styles=styles)

if name == ' main


':
app.run(debug=True)
Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

10. Write a php flask code to open following pages:


a) About us
b) Contact us
c) Registration
d) Login
in flask render template.
mai.py
from flask import Flask, render_template
app = Flask( name )

# Route to render another page


@app.route('/')
def about():
return render_template('about.php')

# Route to render a template


@app.route('/contacts')
def contacts():
return render_template('contacts.php')

# Route to render a template


@app.route('/reg')
def reg():
return render_template('reg.php')

# Route to render a template


@app.route('/login')
def login():
return render_template('login.php')

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

if name == ' main


':
app.run(debug=True)
about.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>About Us</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}

.about-container {
max-width:
1200px; margin: 0
auto; padding:
20px;
background-color: #fff;
box-shadow: 0 0 10px
rgba(0,0,0,0.1); border-radius: 8px;
}

h1 {

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

color: #333;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

.about-content {
margin: 20px 0;
}

.team-section {
display: flex;
justify-content: space-
around; margin-top: 40px;
}

.team-member {
text-align:
center; margin: 0
20px;
}

.team-member img {
border-radius:
50%; width: 150px;
height: 150px;
}

.team-member h3 {
color: #555;
}

.team-member p {
color: #777;
}

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

.about-container p
{ line-height:
1.6;
}
</style>
</head>
<body>
<div class="about-container">
<h1>About Us</h1>
<div class="about-content">
<p>Welcome to our company! We are dedicated to providing the best products
and services in the industry. Our team is committed to ensuring customer satisfaction and
delivering quality solutions to our clients.</p>
<p>Founded in 2020, we have quickly grown to become a leader in our field. We
believe in innovation, excellence, and customer-centric approaches.</p>
</div>

<h2>Meet Our Team</h2>


<div class="team-section">
<div class="team-member">
<h3>keval</h3>
<p>CEO & Founder</p>
</div>

<div class="team-member">
<h3>keval</h3>
<p>Chief Marketing Officer</p>
</div>

<div class="team-member">
<h3>keval</h3>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

<p>Head of Design</p>
</div>
</div>
</div>
</body>
</html>
Contacts.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Contact Us</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#f9f9f9; margin: 0;
padding: 0;
}

.contact-container {
max-width:
800px; margin:
50px auto;
padding: 20px;
background-color:
#fff; border-radius:
10px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

h1 {
text-align: center;
color: #333;
}

form {
display: flex;
flex-direction: column;
}

label {
margin-bottom:
10px; font-weight:
bold;
}

input, textarea {
padding: 10px;
margin-bottom:
20px; border-radius:
5px;
border: 1px solid #ccc;
width: 100%;
}

input[type="submit"] {
background-color:
#28a745; color: #fff;
border: none;
cursor: pointer;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

padding: 15px;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

input[type="submit"]:hover {
background-color: #218838;
}

.message {
text-align: center;
color: green;
}

.error {
color: red;
}
</style>
</head>
<body>
<div class="contact-container">
<h1>Contact Us</h1>

<!-- Form with POST method -->


<form method="post">
<label for="name">Name</label>
<input type="text" id="name" name="name" >

<label for="email">Email</label>
<input type="text" id="email" name="email" >

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

<label for="message">Message</label>
<textarea id="message" name="message" rows="5"></textarea>

<input type="submit" value="Submit">


</form>
</div>
</body>
</html>
Log.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#f4f4f4;
}

.login-container {
max-width:
600px; margin:
50px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 15px rgba(0, 0, 0,

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

0.1); border-radius: 10px;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

h1 {
text-align: center;
color: #333;
}

form {
display: flex;
flex-direction: column;
}

label {
margin: 10px 0
5px; font-weight:
bold;
}

input[type="email"], input[type="password"] {
padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: 1px solid
#ccc;
}

input[type="submit"] {
background-color:
#007bff; color: white;
border: none;
padding: 15px;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

cursor: pointer;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

input[type="submit"]:hover {
background-color: #0056b3;
}

</style>
</head>
<body>
<div class="login-container">
<h1>Login</h1>

<!-- Form to capture login details -->


<form method="POST">
<label for="email">Email</label>
<input type="email" id="email" name="email">

<label for="password">Password</label>
<input type="password" id="password" name="password">

<input type="submit" value="Login">


</form>
</div>
</body>
</html>
Reg.php
<!DOCTYPE html>
<html lang="en">
<head>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Registration</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#f4f4f4;
}

.register-container {
max-width:
600px; margin:
50px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 15px rgba(0, 0, 0,
0.1); border-radius: 10px;
}

h1 {
text-align: center;
color: #333;
}

form {
display: flex;
flex-direction: column;
}

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

label {

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

margin: 10px 0
5px; font-weight:
bold;
}

input[type="text"], input[type="email"], input[type="password"] {


padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: 1px solid
#ccc;
}

input[type="submit"] {
background-color:
#28a745; color: white;
border: none;
padding: 15px;
cursor: pointer;
}

input[type="submit"]:hover {
background-color: #218838;
}

.error {
color: red;
}

.success-message {
text-align:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

center; color:
green;

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

}
</style>
</head>
<body>
<div class="register-container">
<h1>Register</h1>

<!-- Form to capture registration details -->


<form method="POST">
<label for="username">Username</label>
<input type="text" id="username" name="username">

<label for="email">Email</label>
<input type="email" id="email" name="email">

<label for="password">Password</label>
<input type="password" id="password" name="password">

<input type="submit" value="Register">


</form>

</div>
</body>
</html>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Output:

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

11. Write a php flask program using jinja

delimiters. app.py

from flask import Flask, render_template

app = Flask( name )

# Route to render the template

@app.route('/')

def render_template_example():

return render_template('example.html',

variable_name="'keval",

list_items=["Dancing", "Cooking", "Coding"])

if name == ' main ':

app.run(debug=True)

example.html

<!DOCTYPE html>

<html>

<head>

<title>Jinja2 Delimiters Example</title>

</head>

<body>

<h1>Jinja2 Delimiters Example</h1>

<h3>OutPut From Variable Insertion</h3>

<p>My Name Is {{ variable_name }}</p>

<h3>OutPut From Expression</h3>

<p>Addition: {{ 10 + 3 }}</p>

<h3>OutPut From Control Statements</h3>

{% if 'keval' in variable_name %}

<p>My Name is 'keval'</p>

{% else %}

<p>The variable does not contain the word 'keval'</p>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

{% endif %}

<h3>OutPut From Loop</h3>

<p>My Hobbies Are : </p>

<ul>

{% for item in list_items %}

<li>{{ item }}</li>

{% endfor %}

</ul>

</body>

</html>

Roll no. Page


SHRINATHJI COLLEGE OF COMPUTER APPLICATION (A.Y- 2024-2025)

Output:

Roll no. Page

You might also like