Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. <?php
  2. if(empty($_POST['firstname'])){
  3. $error['firstname'] = 'Firstname is empty!';
  4. }
  5. if(empty($_POST['lastname'])){
  6. $error['lastname'] = 'Lastname is empty!';
  7. }
  8. if(empty($_POST['email'])){
  9. $error['email'] = 'Email is empty!';
  10. }
  11. if(empty($_POST['password'])){
  12. $error['password'] = 'Password is empty!';
  13. }
  14. if(empty($_POST['password-confirm'])){
  15. $error['password-confirm'] = 'Password and password confirmation not match!';
  16. }
  17. if(empty($_POST['password-confirm'])){
  18. $error['password-confirm'] = 'Password confirmation is empty!';
  19. }
  20. if(!empty($_POST['password-confirm']) && !empty($_POST['password']) ){
  21. if($_POST['password-confirm'] == $_POST['password']){
  22. $error['password-confirm'] = 'Password confirmation and password is not match!';
  23. }
  24. }
  25.  
  26. ?>
  27. <!DOCTYPE html>
  28. <html lang="en" dir="ltr">
  29. <head>
  30. <meta charset="utf-8">
  31. <title>Form Validation</title>
  32. <link rel="stylesheet" href="css/bootstrap.min.css">
  33. <link rel="stylesheet" href="css/fontawesome-all.min.css">
  34. </head>
  35. <body>
  36. <div class="container py-5">
  37. <div class="col-8 offset-2">
  38. <h1>Form Validation</h1>
  39. <form action="" method="post">
  40. <div class="form-group">
  41. <label for="firstname">First Name</label>
  42. <input type="text" name="firstname" id="firstname" class="form-control" autofocus placeholder="First Name">
  43. <?php if(!empty($_POST) && !empty($error['firstname'])): ?>
  44. <div class="alert alert-danger" role="alert">
  45. <?php echo $error['firstname'] ?>
  46. </div>
  47. <?php endif; ?>
  48. </div>
  49. <div class="form-group">
  50. <label for="lastname">Last Name</label>
  51. <input type="text" name="lastname" id="lastname" class="form-control" placeholder="Last Name">
  52. <?php if(!empty($_POST) && !empty($error['lastname'])): ?>
  53. <div class="alert alert-danger" role="alert">
  54. <?php echo $error['lastname'] ?>
  55. </div>
  56. <?php endif; ?>
  57. </div>
  58. <div class="form-group">
  59. <label for="email">Email</label>
  60. <input type="email" name="email" id="email" class="form-control" placeholder="Email">
  61. <?php if(!empty($_POST) && !empty($error['email'])): ?>
  62. <div class="alert alert-danger" role="alert">
  63. <?php echo $error['email'] ?>
  64. </div>
  65. <?php endif; ?>
  66. </div>
  67. <div class="form-group">
  68. <label for="password">Password</label>
  69. <input type="password" name="password" id="password" class="form-control" placeholder="Password">
  70. <?php if(!empty($_POST) && !empty($error['password'])): ?>
  71. <div class="alert alert-danger" role="alert">
  72. <?php echo $error['password'] ?>
  73. </div>
  74. <?php endif; ?>
  75. </div>
  76. <div class="form-group">
  77. <label for="password-confirm">Password Confirmation</label>
  78. <input type="password" name="password-confirm" id="password-confirm" class="form-control" placeholder="Password Confirmation">
  79. <?php if(!empty($_POST) && !empty($error['password-confirm'])): ?>
  80. <div class="alert alert-danger" role="alert">
  81. <?php echo $error['password-confirm'] ?>
  82. </div>
  83. <?php endif; ?>
  84. </div>
  85. <button class="btn btn-info">Send</button>
  86. </form>
  87. </div>
  88. </div>
  89. </body>
  90. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement