PHP Project

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Name of the Topic

Prepared By

Sr.
Name Enroll. No. Dept. Sign.
No.

1. Sevak Bhavy Mahesh Kumar 229720316049 IT

2. Raval Kaushal Jayesh bhai 229720316043 IT

3. Mehta Fenil Bipin Bhai 229720316016 IT

4. Sutaria Priyanshu Himmat Bhai 229720316056 IT

Guided By

Hitesh sir
Lecturer in Machine Learning
Government Polytechnic, Kheda

A micro project submitted to Government Polytechnic, Kheda.

In partial fulfillment of the requirements for the Diploma

Engineering in Semister-4 on 14th May, 2024.

Page 1 of 8
Government Polytechnic, Kheda

Certificate
This is to certify that a microproject of Php(4341603) for

the project entitled, “Login Form” was carried out by the

group of students of Government Polytechnic, Kheda for

partial fulfillment of Diploma in Information Technology

Engineering.

Date: 14-05-2024
Place: Kheda (Raska)

Page 2 of 8
Acknowledgement

First and foremost, I would like to thank our English


Teacher Hitesh sir who guided us in doing these projects. He
provided us with invaluable advice and helped us in difficult
periods. His motivation and help contributed tremendously to
the successful completion of the project.

Besides, we would like to thank all the teachers who helped


us by giving us advice and providing the equipment which we
needed.

Also I would like to thank my family and friends for their


support. Without that support we couldn’t have succeeded in
completing this project.

At last but not in least, we would like to thank everyone who


helped and motivated us to work on this project.

Thanking You.

Page 3 of 8
INTRODUCTION
PHP is a general-purpose Scripting language geared
towards web development. It was originally created by Danish-
Canadian programmer Rasmus Lerdorf in 1993 and released in
1995. The PHP reference implementation is now produced by the
PHP Group.

Some Important feature of php are given below:

o Open Source
o Embedded
o Plate form Independent
o Database Support
o Error Reporting
o Loosely Typed Language

The main advantage of Php are given below:

o PHP’s Compatibility with a wide range of database is one


of its major advantages in web development. With PHP,
developers can connect to almost any type of database,
including MySQL, msql, MS-SQL, SQLite, PostgreSQL,
Redis, MongoDB, and Many Others.

o The PHP micro project for a login form is a simple yet effective way to
understand the basics of PHP and MySQL integration for user
authentication. This project involves creating a basic login form using
HTML and CSS, and then using PHP to process the form data and validate it
against a MySQL database.

Project Overview:
1. Setting up the development environment:
-Install a local server (e.g., XAMPP, WAMP, or MAMP)
-Create a new database and table in MySQL for storing user data.

2. Designing the login form:


-Create an HTML file with a form containing fields for username
and password

Page 4 of 8
-Style the form using CSS to make it visually appealing

3.Connecting to the database:


-Use PHP's built-in functions to establish a connection to the
MySQL database
-Write SQL queries to fetch user data from the database.

4.Processing the form data:


-Use PHP to retrieve form data and sanitize it to prevent SQL
injection attacks
-Compare the submitted username and password with the data in
the database
-If the credentials match, create a session and redirect the user to a
welcome page
-If the credentials do not match, display an error message

5.Implementing security measures:


-Use prepared statements or parameterized queries to prevent SQL
injection attacks
-Hash passwords using a secure algorithm (e.g., crypt or Argon2)
before storing them in the database
-Implement a timeout for inactive sessions to improve security

6.Testing and debugging:


-Test the login form with various test cases to ensure it works as
expected
-Debug any issues that arise during testing and make necessary
adjustments

Page 5 of 8
Code:

<html>
<head>
<title>Login</title>
<style>
body{
margin-top:100px;
margin-bottom:100px;
margin-right:150px;
margin-left:80px;
background-color: azure;
font-family :Verdana;
font-size:100%;
}
h1{
color: indigo;
font-family :Verdana;
font-size:100%;
}
h3{
color: indigo;
font-family: Verdana;
font-size:100%;
}</style>
</head>
<body>
<center><h1>WELCOME TO ONLINE ART GALLERY</h1></center>
<center><h3>Login Form</h3></center>
<form action=""method="POST">
<legend><fieldset><center>
Username:<input type="text name ="user"><br><br>
password:<input type="password" name="pass"><br><br>
<input type ="submit" value="Login" name="submit" style="background-
color: lightblue; color: darkblue">
</center><fieldset><legend></form>
<?php
if(isset($_POST["submit"])){
if(!empty($_POST['user'])&& !empty($_POST['pass])){
$user=$_POST['user'];
$pass=$_POST['pass'];
$con=mysqli_connect('localhost',root',",'product2') or die(mysql_error());
$query=mysqli_query($con,"SELECT* FROM user WHERE name
="".$user."AND password="".$pass."");
$numrows=mysqli_num_rows($query);
Page 6 of 8
if($numrows !=0)
{
while($row=mysqli_fetch_assoc($query))
{
$dbusername=$row['name'];
$dbpassword=$row['password'];
}
if($user==$dbusername && $pass ==$dbpassword)
{
session_start();
$_SESSION['sess_user']=$user;
else{echo"Invalid username or password!";
}}else{
echo” All fields are required!";}
} ?>
</body>
</html>

Output:

Page 7 of 8
Conclusion:
- This PHP micro project for a login form is an excellent way to
learn the basics of PHP and MySQL integration for user authentication.
By following the steps outlined above, you will gain hands-on
experience in creating a functional login form that can be used as a
foundation for more complex web applications.

Thank you very much for


reading the report of our
Machine Learning
microproject
Page 8 of 8

You might also like