Authentication Secure Login, Registration and View Profile

Authentication Secure Login, Registration and View Profile where the users of your websites can be able to create their accounts, and log in with their valid information so as to access the system to their various accounts. Users information during registration process have been validated and stored in the database. The system can show you the details about your profile that you've been created before and after you logging in. The system validates new users for duplicate email addresses and performs valid authentication during registered users log in. And this is compose of PHP and MySql, this programs are written in a way that any one can understand and customize.

Sample Code

Index.php - And for the login page here is the scripted code to be use.
  1. <?php
  2. $conn = mysql_connect("localhost","root","") or die (mysql_error());
  3. $db=mysql_select_db('securelog',$conn) or die (mysql_error());
  4.  
  5. if(isset($_POST['submit'])){
  6.  
  7. $email=$_POST['email'];
  8. $pass=$_POST['pass'];
  9.  
  10. if($email==''){
  11.  
  12. echo "<script>alert('Email Id Incorrect, try again..')</script>";
  13. exit();
  14. }
  15.  
  16. if($pass==''){
  17.  
  18. echo "<script>alert('Password Incorrect, try again.. !!')</script>";
  19. exit();
  20. }
  21. else
  22. {
  23.  
  24. $query="select * from user_reg where email='$email' AND pass='$pass'";
  25. $run=mysql_query($query) or die (mysql_error());
  26.  
  27. if(mysql_num_rows($run)==1){
  28.  
  29. echo "<script>alert('Your Logged in Successfully !!')</script>";
  30. echo "<script>window.open('home.php','_self')</script>";
  31. }
  32. }
  33. }
  34. ?>
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <title>Authentication Secure Login, Registration and View Profile</title>
  39. <link rel="stylesheet" href="css/bootstrap.min.css">
  40. <script src="js/jquery.min.js"></script>
  41. <script src="js/bootstrap.min.js"></script>
  42. </head>
  43. <body>
  44. <h2 align="center"><em>Authentication Secure Login, Registration and View Profile</em></h2>
  45. <div class="container">
  46. <form action="" method="post">
  47. <h2 align="center"><em>Sign In Here !!</em></h2>
  48. <div class="form-group">
  49. <label for="email">Email address</label>
  50. <input type="email" name="email" class="form-control" id="email" required>
  51. </div>
  52. <div class="form-group">
  53. <label for="pwd">Password</label>
  54. <input type="password" name="pass" class="form-control" id="pwd" required>
  55. </div>
  56. <div class="checkbox">
  57. <label><input type="checkbox"> Remember me</label>
  58. <label><a href="reg.php" style="color:#fff"> <b>Sign Up</label>
  59. </div>
  60. <button type="submit" name="submit" class="btn btn-default">Submit</button>
  61. </form>
  62. </div>
  63. </body>
  64. </html>
ResultReg.php - For the registration of users here is the sample code.
  1. <?php
  2. $conn=mysql_connect("localhost","root","") or die (mysql_error());
  3. $db=mysql_select_db('securelog',$conn) or die (mysql_error());
  4.  
  5. if(isset($_POST['Submit']))
  6. {
  7. $fname=$_POST['fname'];
  8. $lname=$_POST['lname'];
  9. $pass=$_POST['pass'];
  10. $cpass=$_POST['cpass'];
  11. $email=$_POST['email'];
  12. $mo=$_POST['mobile'];
  13. $city=$_POST['city'];
  14.  
  15. if($fname=='')
  16. {
  17. echo "<script>alert('Please Enter First Name')</script>";
  18. exit();
  19. }
  20. if($lname=='')
  21. {
  22. echo "<script>alert('Please Enter Last Name')</script>";
  23. exit();
  24. }
  25. if($pass=='')
  26. {
  27. echo "<script>alert('Please Enter a Password')</script>";
  28. exit();
  29. }
  30. if($cpass=='')
  31. {
  32. echo "<script>alert('Password is do not Match,Please try again')</script>";
  33. exit();
  34. }
  35. if($email=='')
  36. {
  37. echo "<script>alert('Please Enter Email')</script>";
  38. exit();
  39. }
  40. if($mo=='')
  41. {
  42. echo "<script>alert('Please Enter Mobile No')</script>";
  43. exit();
  44. }
  45. if($city=='')
  46. {
  47. echo "<script>alert('Please Enter City')</script>";
  48. exit();
  49. }
  50. else
  51. {
  52.  
  53. $query="insert into user_reg(fname,lname,pass,cpass,email,mobile,city) values ('$fname','$lname','$pass','$cpass','$email','$mo','$city')";
  54.  
  55. if(mysql_query($query)){
  56.  
  57. echo "<script>alert('Signing Successfully !!')</script>";
  58. echo "<script>window.open('index.php','_self')</script>";
  59.  
  60. }
  61. }
  62. }
  63. ?>
ResultProfile.php -and for the viewing of each users profile from the database to display in the webpage.
  1. <div align="center" class="container">
  2. <h3>My Profile</h3>
  3. <?php
  4. include "connect.php";
  5. $q="select * from user_reg order by id asc";
  6. $result = mysql_query($q);
  7. while($rs=mysql_fetch_array($result)){
  8. $fname=$rs['fname'];
  9. $lname=$rs['lname'];
  10. $email=$rs['email'];
  11. $mobile=$rs['mobile'];
  12. $city=$rs['city'];
  13. echo "
  14. <table class='table table-condensed'>
  15. <thead>
  16. <tr>
  17. <th>Firstname</th>
  18. <th>Lastname</th>
  19. <th>Email</th>
  20. <th>Mobile</th>
  21. <th>City</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. <tr>
  26. <td>".$fname."</td>
  27. <td>".$lname."</td>
  28. <td>".$email."</td>
  29. <td>".$mobile."</td>
  30. <td>".$city."</td>
  31. </tr>
  32. </tbody>
  33. </table>";
  34. }
  35. ?>
  36. </div>
ResultHope that you learn in this tutorial. And for more updates and programming tutorials don't hesitate to ask and we will answer your suggestions. Don't forget to LIKE & SHARE this website.

Add new comment