PHP Project
PHP Project
PHP Project
Prepared By
Sr.
Name Enroll. No. Dept. Sign.
No.
Guided By
Hitesh sir
Lecturer in Machine Learning
Government Polytechnic, Kheda
Page 1 of 8
Government Polytechnic, Kheda
Certificate
This is to certify that a microproject of Php(4341603) for
Engineering.
Date: 14-05-2024
Place: Kheda (Raska)
Page 2 of 8
Acknowledgement
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.
o Open Source
o Embedded
o Plate form Independent
o Database Support
o Error Reporting
o Loosely Typed Language
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.
Page 4 of 8
-Style the form using CSS to make it visually appealing
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.