Simple PHP Login Script PHP7 Login Script Simple Tutorial Login Script

Simplest PHP Login Script PHP7 Login Script Simple Tutorial Login Script

Demo Link

Create a directory say "php_script_login"

  1. First File with name "index.php" PS: you create file with ext ".php" and NOT ".php.txt"
  2. Second File with name "loggingin.php" PS: you create file with ext ".php" and NOT ".php.txt"
Place both the files in directory "php_script_login" now if you want to test the script in local machine. Place this directory "php_script_login" in the PHP Server (LAMP / XAMPP / WAMP) inside directory "www" and "htdocs" in case of XAMPP. Make sure PHP server (LAMP / WAMP / XAMPP) is running.
If you dont have PHP Server Installed in your machine Learn to Install XAMPP in your Windows Machine and Learn to Install LAMP in your Linux Machine
Call the URL in your browser http://localhost/php_script_login

If you want to test the script directly in server Place this directory "php_script_login" in your Server and check by Calling the URL in your browser www.yourdomain.com/php_script_login

index.php
  1. <h3>Login Script in PHP (Demo)</h3>
  2. <div class="form">
  3. <form action="loggingin.php" method="post">
  4. User Name: <input type="text" name="user_id"><br>
  5. Password : <input type="password" name="user_passwd"><br>
  6. <input type="submit" value="login"><br>
  7. </form>
  8. </div>
  9. .form{
  10. border: 1px solid #D3D3D3;
  11. text-align: center;
  12. width: 200px;
  13. }



loggingin.php
  1. <?php
  2. $user_id = $_POST['user_id'] ;
  3. $user_passwd = $_POST['user_passwd'] ;
  4. ?>
  5. <center>
  6. <?php
  7. if($user_id =="john" && $user_passwd =="john@123")
  8. {
  9. echo "<h3>Correct</h3>" ;
  10. }
  11. else
  12. {
  13. echo "<h3>Incorrect</h3>" ;
  14. }
  15. ?>
  16. </div>
  17. </center>

If You Think This Post has helped you buy us a Coffee :)

Make Donation

  • Other: $

Donate now