Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REGISTER
- <!doctype html>
- <html>
- <head>
- <title>Register</title>
- <style>
- body{
- margin-top: 100px;
- margin-bottom: 100px;
- margin-right: 750px;
- margin-left: 300px;
- background-image: url("ebook.jpg");
- font-family: verdana;
- color:White;
- }
- h1 {
- color: cyan;
- font-family: verdana;
- font-size: 100%;
- }
- h2 {
- color: cyan;
- font-family: verdana;
- font-size: 100%;
- h3{
- font-size : 50px;
- color:LightGray;
- }
- }</style>
- </head>
- <body> <h3 style="color:White;font-size:30px">EBOOKS</h3>
- <center><h1>RegistrationProcess</h1></center>
- <p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
- <form action="" method="POST">
- <legend>
- <fieldset>
- Username:<br> <input type="text" name="user"><br />
- Password:<br> <input type="password" name="pass"><br /> <br><br>
- <input type="submit" value="Register" name="submit" />
- </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','ram@12111997','user_registration') or die(mysql_error()); $query=mysqli_query($con,"SELECT * FROM login WHERE username='".$user."'");
- $numrows=mysqli_num_rows($query);
- if($numrows==0)
- {
- $sql="INSERT INTO login(username,password) VALUES('$user','$pass')";
- $result=mysqli_query($con,$sql);
- if($result){
- echo "Account Successfully Created Please Login to continue";
- } else {
- echo "Failure!";
- }
- } else {
- echo "That username already exists! Please try again with another.";
- }
- } else {
- echo "All fields are required!";
- }
- }
- ?>
- </body>
- </html>
- /
- /
- /
- LOGIN
- <!doctype html>
- <html>
- <head>
- <title>Login</title>
- <style>
- body{
- margin-top: 100px;
- margin-bottom: 100px;
- margin-right: 150px;
- margin-left: 900px;
- background-image: url("ebook1.jpg");
- color: palevioletred;
- font-family: verdana;
- font-size: 100%
- }
- h1 {
- color: Black;
- font-family: verdana;
- font-size: 100%;
- }
- h3 {
- color: cyan;
- font-family: verdana;
- font-size: 100%;
- } </style>
- </head>
- <body> <h3 style="color:Black;font-size:30px">EBOOKS</h3>
- <h1>Login Process</h1>
- <p><a href="register.php">Register</a> | <a href="login.php">Login</a></p>
- <form action="" method="POST">
- Username:<br> <input type="text" name="user"><br />
- Password:<br> <input type="password" name="pass"><br /> <br><br>
- <input type="submit" value="Login" name="submit" />
- </form>
- <?php
- if(isset($_POST["submit"])){
- if(!empty($_POST['user']) && !empty($_POST['pass'])) {
- $user=$_POST['user'];
- $pass=$_POST['pass'];
- $con=mysqli_connect('localhost','root','ram@12111997','user_registration') or die(mysql_error());
- $query=mysqli_query($con,"SELECT * FROM login WHERE username='".$user."' AND password='".$pass."'");
- $numrows=mysqli_num_rows($query);
- if($numrows!=0)
- {
- while($row=mysqli_fetch_assoc($query))
- {
- $dbusername=$row['username'];
- $dbpassword=$row['password'];
- }
- if($user == $dbusername && $pass == $dbpassword)
- {
- session_start();
- $_SESSION['sess_user']=$user;
- /* Redirect browser */
- header("Location: member.php");
- }
- } else {
- echo "Invalid username or password!";
- }
- } else {
- echo "All fields are required!";
- }
- }
- ?>
- </body>
- </html>
- //
- /
- /
- mEMBER
- <?php
- session_start();
- if(!isset($_SESSION["sess_user"])){
- header("location:login.php");
- } else {
- ?>
- <!doctype html>
- <html>
- <head>
- <title>Welcome</title>
- <style>
- body{
- margin-top: 100px;
- margin-bottom: 100px;
- margin-right: 150px;
- margin-left: 80px;
- background-color: azure ;
- color: palevioletred;
- font-family: verdana;
- font-size: 100%
- }
- h2 {
- color: indigo;
- font-family: verdana;
- font-size: 100%;
- }
- h1 {
- color: indigo;
- font-family: verdana;
- font-size: 100%;
- }
- </style>
- </head>
- <body>
- <h2>Welcome, <?=$_SESSION['sess_user'];?>! <a href="logout.php">Logout</a></h2>
- </body>
- </html>
- <?php
- }
- ?> /
- /
- /
- LOGOUT
- <?php
- session_start();
- unset($_SESSION['sess_user']);
- session_destroy();
- header("location:login.php");
- ?>
Add Comment
Please, Sign In to add comment