registration login html php code complete and easy
Database:
connect.php:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tutor_db";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
?>
registration.php:
<?php
include 'connect.php';
error_reporting(0);
$emp_name=$_POST["name"];
$emp_age=$_POST["username"];
$idcard=$_POST["password"];
$fname=$_POST["category"];
$sub=$_POST["subject"];
$phone=$_POST["phone"];
$email=$_POST["email"];
$msg = '';
if($_SERVER['REQUEST_METHOD']=='POST'){
$image = $_FILES['image']['tmp_name'];
$img = file_get_contents($image);
$con = mysqli_connect('localhost','root','','tutor_db') or die('Unable To connect');
$sql="INSERT INTO reg_tbl (ame,username,password,category,subjects,phone,email,image)
VALUES('$emp_name','$emp_age','$idcard','$fname','$sub','$phone','$email',?)";
$stmt = mysqli_prepare($con,$sql);
mysqli_stmt_bind_param($stmt, "s",$img);
mysqli_stmt_execute($stmt);
$check = mysqli_stmt_affected_rows($stmt);
if($check==1){
$msg = 'Successfullly UPloaded';
}else{
$msg = 'Could not upload';
}
mysqli_close($con);
}
?>
<form role="form" method="post" enctype="multipart/form-data">
<br/>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-circle-o-notch" ></i></span>
<input type="text" class="form-control" placeholder="Your Name" name="name"/>
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-tag" ></i></span>
<input type="text" class="form-control" placeholder="Desired Username" name="username" />
</div>
<div class="form-group input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" placeholder="Your Email" name="email" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="password" class="form-control" placeholder="Enter Password" name="password" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="phone" class="form-control" placeholder="Enter phone" name="phone" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="checkbox" class="" name="category" value="teacher" />Teacher
<input type="checkbox" class="" name="category" value="student" />Student
</div>
<input type="file" name="image" />
<button type="submit" value="submit" name="submit" class="btn btn-success ">Sign Up</button>
<hr />
Already Registered ? <a href="index.php" >Login here</a>
</form>
login.php:
<!DOCTYPE html>
<?php
error_reporting(0);
ob_start();
session_start();
include_once('connect.php');
$msg='';
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$sql="SELECT * FROM reg_tbl where username='$username' and password='$password' ";
$result=mysqli_query($con, $sql);
if ($result) {
$row=mysqli_fetch_array($result);
if ($password=$row['password']) {
$_SESSION['admin_id']=$row['admin_id'];
$_SESSION['username']=$row['username'];
header('Location: dashboard.php');
}
$msg= "<div class='alert alert-danger'><strong>Faild!</strong> Password not match. Please! try with correct one.</div>";
}
else
{
$msg= "<div class='alert alert-danger'><strong>Faild!</strong> User with this username not exists. Please! try with correct one.</div>";
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Teacher Reg</title>
<?php
include 'css.php';
?>
</head>
<body>
<div class="container">
<div class="row text-center ">
<div class="col-md-12">
<br /><br />
<h2> Teacher : Login</h2>
<h5>( Login yourself to get access )</h5>
<br />
</div>
</div>
<div class="row ">
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1">
<div class="panel panel-default">
<div class="panel-heading">
<strong> Enter Details To Login </strong>
</div>
<div class="panel-body"><?php echo $msg; ?></p>
<form role="form" method="post">
<br />
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-tag" ></i></span>
<input type="text" class="form-control" placeholder="Your Username " name="username"/>
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="password" class="form-control" placeholder="Your Password" name="password" />
</div>
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" /> Remember me
</label>
<!-- <span class="pull-right">
<a href="#" >Forget password ? </a>
</span>-->
</div>
<button required type="submit" class="btn btn-primary" name="submit">Login Now</button>
<hr />
Not register ? <a href="registration.php" >click here </a>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
<?php
include 'scripts.php';
?>
</html>
connect.php:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "tutor_db";
// Create connection
$con = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
}
?>
registration.php:
<?php
include 'connect.php';
error_reporting(0);
$emp_name=$_POST["name"];
$emp_age=$_POST["username"];
$idcard=$_POST["password"];
$fname=$_POST["category"];
$sub=$_POST["subject"];
$phone=$_POST["phone"];
$email=$_POST["email"];
$msg = '';
if($_SERVER['REQUEST_METHOD']=='POST'){
$image = $_FILES['image']['tmp_name'];
$img = file_get_contents($image);
$con = mysqli_connect('localhost','root','','tutor_db') or die('Unable To connect');
$sql="INSERT INTO reg_tbl (ame,username,password,category,subjects,phone,email,image)
VALUES('$emp_name','$emp_age','$idcard','$fname','$sub','$phone','$email',?)";
$stmt = mysqli_prepare($con,$sql);
mysqli_stmt_bind_param($stmt, "s",$img);
mysqli_stmt_execute($stmt);
$check = mysqli_stmt_affected_rows($stmt);
if($check==1){
$msg = 'Successfullly UPloaded';
}else{
$msg = 'Could not upload';
}
mysqli_close($con);
}
?>
<form role="form" method="post" enctype="multipart/form-data">
<br/>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-circle-o-notch" ></i></span>
<input type="text" class="form-control" placeholder="Your Name" name="name"/>
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-tag" ></i></span>
<input type="text" class="form-control" placeholder="Desired Username" name="username" />
</div>
<div class="form-group input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" placeholder="Your Email" name="email" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="password" class="form-control" placeholder="Enter Password" name="password" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="phone" class="form-control" placeholder="Enter phone" name="phone" />
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="checkbox" class="" name="category" value="teacher" />Teacher
<input type="checkbox" class="" name="category" value="student" />Student
</div>
<input type="file" name="image" />
<button type="submit" value="submit" name="submit" class="btn btn-success ">Sign Up</button>
<hr />
Already Registered ? <a href="index.php" >Login here</a>
</form>
login.php:
<!DOCTYPE html>
<?php
error_reporting(0);
ob_start();
session_start();
include_once('connect.php');
$msg='';
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$sql="SELECT * FROM reg_tbl where username='$username' and password='$password' ";
$result=mysqli_query($con, $sql);
if ($result) {
$row=mysqli_fetch_array($result);
if ($password=$row['password']) {
$_SESSION['admin_id']=$row['admin_id'];
$_SESSION['username']=$row['username'];
header('Location: dashboard.php');
}
$msg= "<div class='alert alert-danger'><strong>Faild!</strong> Password not match. Please! try with correct one.</div>";
}
else
{
$msg= "<div class='alert alert-danger'><strong>Faild!</strong> User with this username not exists. Please! try with correct one.</div>";
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Teacher Reg</title>
<?php
include 'css.php';
?>
</head>
<body>
<div class="container">
<div class="row text-center ">
<div class="col-md-12">
<br /><br />
<h2> Teacher : Login</h2>
<h5>( Login yourself to get access )</h5>
<br />
</div>
</div>
<div class="row ">
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1">
<div class="panel panel-default">
<div class="panel-heading">
<strong> Enter Details To Login </strong>
</div>
<div class="panel-body"><?php echo $msg; ?></p>
<form role="form" method="post">
<br />
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-tag" ></i></span>
<input type="text" class="form-control" placeholder="Your Username " name="username"/>
</div>
<div class="form-group input-group">
<span class="input-group-addon"><i class="fa fa-lock" ></i></span>
<input type="password" class="form-control" placeholder="Your Password" name="password" />
</div>
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" /> Remember me
</label>
<!-- <span class="pull-right">
<a href="#" >Forget password ? </a>
</span>-->
</div>
<button required type="submit" class="btn btn-primary" name="submit">Login Now</button>
<hr />
Not register ? <a href="registration.php" >click here </a>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
<?php
include 'scripts.php';
?>
</html>
Comments
Post a Comment