PHP MP
PHP MP
A
MICROPROJECT REPORT ON
Submitted by: -
HOD PRINCIPAL
Acknowledgement
THANK YOU
INDEX
1 Abstract 1
2 Introduction 2
3 Key Features 3
4 Functions used 4
5 Code 5
6 Output 9
7 Conclusion 11
8 References 12
Abstract
1
Introduction
2
Key Features
3
Functions used
• header(): Sends a raw HTTP header to redirect the user to another location or
set cookies.
• $_GET(): Retrieves data sent to the server in the URL query string.
4
Code
<?php
session_start();
include('includes/dbconn.php');
if(isset($_POST['login']))
{
$email=$_POST['email'];
$password=$_POST['password'];
$password = md5($password);
$stmt=$mysqli->prepare("SELECT email,password,id FROM
userregistration WHERE email=? and password=? ");
$stmt->bind_param('ss',$email,$password);
$stmt->execute();
$stmt -> bind_result($email,$password,$id);
$rs=$stmt->fetch();
$stmt->close();
$_SESSION['id']=$id;
$_SESSION['login']=$email;
$uip=$_SERVER['REMOTE_ADDR'];
$ldate=date('d/m/Y h:i:s', time());
if($rs){
$uid=$_SESSION['id'];
$uemail=$_SESSION['login'];
$ip=$_SERVER['REMOTE_ADDR'];
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));
$city = $addrDetailsArr['geoplugin_city'];
$country = $addrDetailsArr['geoplugin_countryName'];
$log="insert into userLog(userId,userEmail,userIp,city,country)
values('$uid','$uemail','$ip','$city','$country')";
$mysqli->query($log);
if($log){
header("location:student/dashboard.php");
}
} else {
5
echo "<script>alert('Sorry, Invalid Username/Email or
Password!');</script>";
}
}
?>
<!-- By CodeAstro - codeastro.com -->
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16"
href="assets/images/favicon.png">
<title>Hostel Management System</title>
<!-- Custom CSS -->
<link href="dist/css/style.min.css" rel="stylesheet">
<script type="text/javascript">
function valid() {
if(document.registration.password.value!=
document.registration.cpassword.value){
alert("Password and Re-Type Password Field do not match !!");
document.registration.cpassword.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<div class="main-wrapper">
6
<div class="preloader">
<div class="lds-ripple">
<div class="lds-pos"></div>
<div class="lds-pos"></div>
</div>
</div>
<div class="auth-wrapper d-flex no-block justify-content-center align-
items-center position-relative"
style="background:url(../assets/images/big/auth-bg.jpg) no-repeat center
center;">
<div class="auth-box row">
<div class="col-lg-7 col-md-5 modal-bg-img" style="background-
image: url(assets/images/hostel-img.jpg);">
</div>
<div class="col-lg-5 col-md-7 bg-white">
<div class="p-3">
<div class="text-center">
<img src="assets/images/big/icon.png" alt="wrapkit">
</div>
<h2 class="mt-3 text-center">Student Login</h2>
</html>
8
Output
Index Page
9
10
Conclusion
11
Reference
• www.geeksforgeeks.com
• www.javatpoint.com
• www.w3schools.com
• https://www.php.net/
• https://www.tutorialspoint.com/php/index.htm
• https://www.codecademy.com/catalog/language/php
12