Advertisement
Guest User

Untitled

a guest
Jul 14th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <form action="validate.php" method="post">
  2. <p>Username: </p><input type="text" name="username" value="" /><br />
  3. <p>Password: </p><input type="password" name="password" value="" /><br />
  4. <br />
  5. <input type="submit" name="submit" value="submit" /><br />
  6. </form>
  7.  
  8. <pre>
  9. <?php
  10. print_r($_POST);
  11. ?>
  12. </pre>
  13.  
  14. <?php
  15. // Uses ternary operator
  16. $username = isset($_POST["username"]) ? $_POST["username"] : NULL;
  17. $password = isset($_POST["password"]) ? $_POST["password"] : NULL;
  18. ?>
  19.  
  20. if (isset($_POST["username])) {
  21. $username = $_POST["username"];
  22. } else {
  23. $username = "";
  24. }
  25.  
  26. if (isset($_POST["password"])) {
  27. $password = $_POST["password"];
  28. } else {
  29. $password = "";
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement