Advertisement
Guest User

Untitled

a guest
May 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2. $error = '';
  3.  
  4. // Form is gesubmit dus let's go on :P
  5. if (array_key_exists('formSubmit', $_POST) && trim($_POST['formSubmit']) != '')
  6. {
  7.     // geen username gevonden
  8.     if (!array_key_exists('username', $_POST) || trim($_POST['username']) == '')
  9.     {
  10.         $error = 'Please enter your username!';
  11.     }
  12.     // Geen password gevonden
  13.     else if (!array_key_exists('password', $_POST) || trim($_POST['password']) == '')
  14.     {
  15.         $error = 'Please enter your password!';
  16.     }
  17.     // Beide velden zijn ingevuld we kunnen door
  18.     else
  19.     {
  20.         // Code voor het controleren of inloggen is gelukt
  21.         // ..............
  22.         // ..............
  23.  
  24.         // Inloggen is gelukt stuur door naar anderepagina.php
  25.         die(header('Location: anderepagina.php'));
  26.     }
  27. }
  28.  
  29. ?>
  30.  
  31. <html>
  32. ...
  33. ...
  34.  
  35.  
  36. <?php
  37. if ($error != '')
  38. {
  39.     echo '<div>ERROR: '.$error.'</div>';
  40. }
  41. ?>
  42. <form name="blaForm" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>" >
  43. Username: <input type="text" name="username" />
  44. Password: <input type="password" name="password" />
  45. <input type="submit" name="formSubmit" value="Log in" />
  46.  
  47. </form>
  48.  
  49.  
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement