sushma_proach

dashboard register and login page

Apr 16th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.77 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Register</title></head>
  4. <body>
  5. <p><a href="register.php">Register</a> | <a href="loginn.php">Login</a></p>
  6. <h3> Registration Form </h3>
  7. <form action="" method="post">
  8. username<input type="text" name="username"/></br>
  9. email id:<input type="email" name="email" /></br>
  10. password<input type="pass" name="password"/></br>
  11. <input type="submit" name="send" value="send"></br>
  12. </form>
  13. <?php
  14. include('db.php');
  15. if(isset($_POST['send'])){
  16. $username=$_POST['username'];
  17. $email=$_POST['email'];
  18. $password=$_POST['password'];
  19. $sql="INSERT INTO login (username,email,password) VALUES ('$username','$email','$password')";
  20. $result=mysqli_query($conn,$sql);
  21. if ($result){
  22.     echo "account successfully created";
  23. }else {
  24.     echo "Failure";
  25. }
  26. }
  27. ?>
  28. </body>
  29. </html>
  30.  
  31. LOGINN.PHP..................................
  32.  
  33. <?php
  34. session_start();
  35. include('db.php');
  36.  
  37. if(isset($_SESSION['username']))
  38. {
  39.   //$_SESSION['username'];
  40. header("Location:home.php");  
  41. }
  42. ?>
  43. <html>
  44. <head>
  45. <title>Register</title></head>
  46. <body>
  47. <p><a href="loginn.php">Login</a></p>
  48. <h3>login</h3>
  49. <form action=""  method="post">
  50. username<input type="text" name="username"/></br>
  51. password<input type="password" name="password"/></br>
  52. <input type="submit" name="send" value="send"></br>
  53. </form>
  54. <?php
  55. if(isset($_POST['send'])){
  56. $username=$_POST['username'];
  57. $password=$_POST['password'];
  58.  
  59. $query="SELECT * FROM login WHERE username= '$username' AND password= '$password'";
  60. $res=mysqli_query($conn,$query);
  61. $numrows=mysqli_num_rows($res);
  62. //echo $numrows;
  63. if($numrows)
  64. {
  65. $_SESSION['username']=$username;
  66. //$_SESSION['pass']=$password;
  67. //echo "valid username and password";  
  68. }
  69. }
  70. ?>
  71. </body>
  72. </html>
  73.  
  74. HOME.PHP>>>>>>>>>>>>>.....
  75.  
  76. <?php
  77. session_start();
  78. if (!(isset($_SESSION['username']) )) {
  79.  
  80. header ("Location:loginn.php");
  81.  
  82. }
  83. echo "welcome" .$_SESSION['username'];
  84. ?>
  85. <a href= "logout.php"> Logout</a>
  86. DB.PHP......................................................................
  87. <html>
  88. <head>
  89. <title>Connection</title>
  90. </head>
  91. <body>
  92. <?php
  93.    $dbhost = 'localhost';
  94.    $dbuser = 'root';
  95.    $dbpass = '';
  96.    $conn = mysqli_connect($dbhost, $dbuser, $dbpass);
  97.    if(!$conn)
  98.    {
  99.      die('Could not connect: ' . mysqli_error());
  100.    }
  101.    //echo 'Connected successfully';
  102.    //mysqli_select_db('information');
  103.    mysqli_select_db($conn, "information");
  104.   ?>
  105. </body>
  106. </html>
  107.  
  108. LOGOUT.PHP...................................
  109.  
  110. <?php
  111. session_start();
  112. if(isset($_SESSION['username']))
  113. {
  114. unset($_SESSION['username']);
  115. header("Location:register.php");
  116. exit();
  117. }
  118.  
  119. ?>
  120.  
  121. RETURN.PHP..............................................
  122.  
  123. <?php  
  124.     include('db.php');  
  125.         header("Location:register.php");  
  126. ?>
Add Comment
Please, Sign In to add comment