Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Register</title></head>
- <body>
- <p><a href="register.php">Register</a> | <a href="loginn.php">Login</a></p>
- <h3> Registration Form </h3>
- <form action="" method="post">
- username<input type="text" name="username"/></br>
- email id:<input type="email" name="email" /></br>
- password<input type="pass" name="password"/></br>
- <input type="submit" name="send" value="send"></br>
- </form>
- <?php
- include('db.php');
- if(isset($_POST['send'])){
- $username=$_POST['username'];
- $email=$_POST['email'];
- $password=$_POST['password'];
- $sql="INSERT INTO login (username,email,password) VALUES ('$username','$email','$password')";
- $result=mysqli_query($conn,$sql);
- if ($result){
- echo "account successfully created";
- }else {
- echo "Failure";
- }
- }
- ?>
- </body>
- </html>
- LOGINN.PHP..................................
- <?php
- session_start();
- include('db.php');
- if(isset($_SESSION['username']))
- {
- //$_SESSION['username'];
- header("Location:home.php");
- }
- ?>
- <html>
- <head>
- <title>Register</title></head>
- <body>
- <p><a href="loginn.php">Login</a></p>
- <h3>login</h3>
- <form action="" method="post">
- username<input type="text" name="username"/></br>
- password<input type="password" name="password"/></br>
- <input type="submit" name="send" value="send"></br>
- </form>
- <?php
- if(isset($_POST['send'])){
- $username=$_POST['username'];
- $password=$_POST['password'];
- $query="SELECT * FROM login WHERE username= '$username' AND password= '$password'";
- $res=mysqli_query($conn,$query);
- $numrows=mysqli_num_rows($res);
- //echo $numrows;
- if($numrows)
- {
- $_SESSION['username']=$username;
- //$_SESSION['pass']=$password;
- //echo "valid username and password";
- }
- }
- ?>
- </body>
- </html>
- HOME.PHP>>>>>>>>>>>>>.....
- <?php
- session_start();
- if (!(isset($_SESSION['username']) )) {
- header ("Location:loginn.php");
- }
- echo "welcome" .$_SESSION['username'];
- ?>
- <a href= "logout.php"> Logout</a>
- DB.PHP......................................................................
- <html>
- <head>
- <title>Connection</title>
- </head>
- <body>
- <?php
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = '';
- $conn = mysqli_connect($dbhost, $dbuser, $dbpass);
- if(!$conn)
- {
- die('Could not connect: ' . mysqli_error());
- }
- //echo 'Connected successfully';
- //mysqli_select_db('information');
- mysqli_select_db($conn, "information");
- ?>
- </body>
- </html>
- LOGOUT.PHP...................................
- <?php
- session_start();
- if(isset($_SESSION['username']))
- {
- unset($_SESSION['username']);
- header("Location:register.php");
- exit();
- }
- ?>
- RETURN.PHP..............................................
- <?php
- include('db.php');
- header("Location:register.php");
- ?>
Add Comment
Please, Sign In to add comment