-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
260 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
basic.html | ||
test.php | ||
welcome.php | ||
signup.php | ||
login.php |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php session_start();?> | ||
|
||
<?php | ||
if(!isset($_SESSION["user"])) | ||
header("Location:login.php"); | ||
?> | ||
<!--Display submitted form data --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Contact Form</title> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
|
||
</head> | ||
|
||
<body> | ||
<h3>Hello <?php echo htmlentities($_SESSION["user"]); ?></h3> | ||
<p>Here is the information you have submitted:</p> | ||
<ol> | ||
<li><em>Name:</em> <?php echo $_SESSION["name"]?> | ||
<li><em>E-Mail:</em> <?php echo $_SESSION["email"]?> | ||
<li><em>Mobile:</em> <?php echo $_SESSION["mobile"]?> | ||
<li><em>Points:</em> <?php echo $_SESSION["points"]?> | ||
<li><em>Username:</em> <?php echo $_SESSION["user"]?> | ||
<li><em>Password:</em> <?php echo $_SESSION["pass"]?> | ||
</ol> | ||
|
||
<div class="col-md-2"> | ||
<form action="logout.php" method="post"><input class="btn btn-block btn-primary" type="submit" name="logout" value="Logout"></form> | ||
</div> | ||
|
||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,216 @@ | ||
<?php | ||
if (!isset($_SESSION)) session_start(); | ||
|
||
//make connection with database | ||
$link = mysqli_connect("localhost","slp","qwerty","libromate"); | ||
// Check connection | ||
if($link === false){ | ||
die("ERROR: Could not connect. " . mysqli_connect_error()); | ||
} | ||
|
||
//if user clicks on login | ||
if(isset($_POST["login"])){ | ||
|
||
$username = $_POST['user']; | ||
$password = $_POST['pass']; | ||
$query="select * from users where username='$username' AND password='$password'"; | ||
$newuser=mysqli_query($link,$query); | ||
|
||
$flag=0; | ||
if(trim($_POST["user"])==NULL){ | ||
$flag=1; | ||
$msg="Username is required!"; | ||
} | ||
else if(trim($_POST["pass"])==NULL){ | ||
$flag=1; | ||
$msg="Password is required!"; | ||
} | ||
else if(!$newuser){ | ||
$flag=1; | ||
$msg="Username or Password incorrect"; | ||
} | ||
else{ | ||
//declaration of global session variables | ||
$_SESSION["user"] = $_POST["user"]; | ||
$_SESSION["pass"] = md5($_POST["pass"]); | ||
|
||
if (mysqli_num_rows($newuser) > 0) | ||
header("Location: dashboard.php"); | ||
} | ||
} | ||
//if user clicks on sign up | ||
else if(isset($_POST["signup"])){ | ||
|
||
$username = $_POST["user"]; | ||
$password = $_POST["pass"]; | ||
$full_name = $_POST["name"]; | ||
$email = $_POST["email"]; | ||
$mobile = $_POST["mobile"]; | ||
$level = 0; | ||
$points = 10; | ||
//check duplicate username | ||
$query="select * from users where username='$username'"; | ||
$newuser=mysqli_query($link,$query); | ||
|
||
$flag=0; | ||
if(trim($_POST["name"])==NULL) | ||
{ | ||
$flag=1; | ||
$msg="Name is required!"; | ||
} | ||
else if(trim($_POST["email"])==NULL) | ||
{ | ||
$flag=1; | ||
$msg="Email is required!"; | ||
} | ||
else if(trim($_POST["mobile"])==NULL) | ||
{ | ||
$flag=1; | ||
$msg="Phone number is required!"; | ||
} | ||
else if(trim($_POST["user"])==NULL) | ||
{ | ||
$flag=1; | ||
$msg="Username is required!"; | ||
} | ||
else if(trim($_POST["pass"])==NULL) | ||
{ | ||
$flag=1; | ||
$msg="Password is required!"; | ||
} | ||
else if(strlen($_POST["pass"])<6) | ||
{ | ||
$flag=1; | ||
$msg="Password should be of minimum 6 letters"; | ||
} | ||
else if(mysqli_num_rows($newuser)!=0) | ||
{ | ||
$flag=1; | ||
$msg="Username already exists"; | ||
} | ||
else if(!is_numeric($_POST["mobile"]) && strlen($_POST["mobile"])!=10) | ||
{ | ||
$flag=1; | ||
$msg="Invalid mobile number "; | ||
} | ||
else{ | ||
//declaration of global session variables | ||
$_SESSION["name"] = $_POST["name"]; | ||
$_SESSION["user"] = $_POST["user"]; | ||
$_SESSION["pass"] = md5($_POST["pass"]); | ||
$_SESSION["email"] = $_POST["email"]; | ||
$_SESSION["mobile"] = $_POST["mobile"]; | ||
$_SESSION["level"] = 0; | ||
$_SESSION["points"] = 10; | ||
//query to insert data to MySQL | ||
$sql = "insert into users (username,password,name,mobile,email,level,points) values ('$username','$password','$full_name','$mobile','$email','$level','$points')"; | ||
$result = mysqli_query($link,$sql); | ||
|
||
//transfer to dashboard | ||
if(mysqli_num_rows($newuser)==0) | ||
header("Location: dashboard.php"); | ||
} | ||
|
||
} | ||
//if any text field is missing or user/pass combination is incorrect | ||
if($flag==1) | ||
{ | ||
$flag=0; | ||
echo '<div class="alert alert-danger alert-dismissable fade in" style="position:absolute;margin-top:580px;margin-left:200px;width:32%;"> | ||
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>'.$msg.' | ||
</div>'; | ||
} | ||
?> | ||
|
||
|
||
<html> | ||
<head> | ||
<link rel="shortcut icon" type="image/png" href="favicon.png"> | ||
<link rel="shortcut icon" type="image/png" href="Images/favicon.png"> | ||
<title>Libromate</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
<link rel="stylesheet" href="style.css" type="text/css"> | ||
</head> | ||
|
||
<body> | ||
<div style="margin-top:150px;margin-left:200px;margin-right:200px;"><!--outer div start--> | ||
<div class="row"><!--row start--> | ||
<div class="col-md-6"><!--col-md-6 start--> | ||
<div class="jumbotron"style="height:350px"><!--login div start--> | ||
<div align="center"> | ||
<h3>Login</h3><br> | ||
<form> | ||
Username : <input type="text" name="uname"><br><br> | ||
Password : <input type="text" name="pws"> | ||
</form> | ||
</div> | ||
</div><!--login div end--> | ||
</div><!--col-md-6 end--> | ||
<div class="col-md-6"><!--col-md-6 start--> | ||
<div class="jumbotron"style="height:350px"><!--sign up div start--> | ||
<div align="center"> | ||
<h3>Sign Up</h3><br> | ||
<form> | ||
Full Name : <input type="text" name="name"><br><br> | ||
E-Mail ID : <input type="text" name="email"><br><br> | ||
Username : <input type="text" name="email"><br><br> | ||
Password : <input type="text" name="email"> | ||
</form> | ||
</div> | ||
</div><!--sign up div end--> | ||
</div><!--col-md-6 end--> | ||
</div><!--row end--> | ||
</div><!--outer div end--> | ||
</body> | ||
<body style="background-color:beige"> | ||
<header style="height:100px;background-color:#6a1b9a;"> | ||
<img src="Images/logo.png" style="height:100px;"> | ||
</header> | ||
|
||
<img src="Images/book.jpg" style ="position:absolute;right:0px;"> | ||
<div id="container" style ="position:absolute;left:835px;font-size:45px;text-align:center;color:beige;font-family:courier;margin-top:45px;margin-left:50px;margin-right:50px;font-variant:small-caps;"> | ||
The more that you read, the more things you will know. The more that you learn, the more places you’ll go. | ||
</div> | ||
|
||
<div style="margin-top:70px;margin-left:200px;margin-right:200px;width:850px;"><!--outer div start--> | ||
<ul class="nav nav-pills"> | ||
<li class="active"><a data-toggle="pill" href="#login">Login</a></li> | ||
<li><a data-toggle="pill" href="#signup">Sign Up</a></li> | ||
</ul> | ||
|
||
<div class="tab-content"><!--tab pill start--> | ||
<div id="login" class="tab-pane fade in active"> | ||
<div class="row"><!--row start--> | ||
<div class="col-md-6"><!--col-md-6 start--> | ||
<div class="jumbotron"style="height:350px;padding-top:15px;background-color:skyblue;box-shadow:5px 5px 5px #c9c9c9;border-radius:5px"><!--login div start--> | ||
<div align="center"><img src="Images/user.png" style="width:150px;"></div> | ||
<form action="login.php" method="post" style="padding-left:75px;padding-right:75px;padding-top:15px;"> | ||
<div class="input-group"> | ||
<span id=1 class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> | ||
<input type="text" class="form-control" name="user" placeholder="Username" value="<?php echo htmlentities($user); ?>"> | ||
</div> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> | ||
<input type="password" class="form-control" name="pass" placeholder="Password"> | ||
</div><br> | ||
<input class="btn btn-block btn-primary" type="submit" name="login" value="Login"> | ||
</form> | ||
</div><!--login div end--> | ||
</div><!--col-md-6 end--> | ||
</div><!--row end--> | ||
</div> | ||
|
||
<div id="signup" class="tab-pane fade"> | ||
<div class="row"><!--row start--> | ||
<div class="col-md-6"><!--col-md-6 start--> | ||
<div class="jumbotron"style="height:350px;padding-top:5px;background-color:skyblue;box-shadow:5px 5px 5px #c9c9c9;border-radius:5px"> | ||
<!--signup div start--> | ||
<form action="login.php" method="post" style="padding-left:75px;padding-right:75px;padding-top:50px;"> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span> | ||
<input type="text" class="form-control" name="name" placeholder="Full Name"> | ||
</div> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span> | ||
<input type="email" class="form-control" name="email" placeholder="Email"> | ||
</div> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-phone"></i></span> | ||
<input type="tel" class="form-control" name="mobile" placeholder="Mobile No"> | ||
</div><br> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> | ||
<input type="text" class="form-control" name="user" placeholder="Username"> | ||
</div> | ||
<div class="input-group"> | ||
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> | ||
<input type="password" class="form-control" name="pass" placeholder="Password"> | ||
</div><br> | ||
<input class="btn btn-block btn-primary" type="submit" name="signup" value="Sign Up"> | ||
<input class="btn btn-block btn-primary" type="reset" name="reset" value="Reset"> | ||
</form> | ||
</div><!--sign up div end--> | ||
</div><!--col-md-6 end--> | ||
</div><!--row end--> | ||
</div> | ||
</div><!--tab pill end--> | ||
</div><!--outer div end--> | ||
|
||
<footer class="footer jumbotron" style="height:100px;margin-top:88px;margin-bottom:0px;background-color:lightgrey"> | ||
<div style="font-size:18px" align="center">© Libromate 2018 | All rights reserved</div> | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
<?php | ||
session_start(); | ||
//intializing all session variables to null | ||
$_SESSION=array(); | ||
//setting cookies to null | ||
if(isset($_COOKIE[$_SESSION])) { | ||
setcookie($_SESSION, '', time() - 42000, '/'); | ||
} | ||
session_destroy(); | ||
//redirecting to login | ||
header("Location:login.php"); | ||
?> | ||
|
||
|
||
|