Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. // $_POST['submit'] NOT SET
  4. if (!isset($_POST['submit'])) { ?>
  5.  
  6. <form action="page.php" method="POST" >
  7. <span>Username: </span><input type="text" name="username" />
  8. <span>Password: </span><input type="text" name="password" />
  9. <span>Repeat ^: </span><input type="password" name="check_password" />
  10. <span>Email Address: </span><input type="email" name="email" />
  11. </form>
  12.  
  13. <?php }
  14.  
  15. // $_POST['submit'] SET
  16. if (isset($_POST['submit'])) {
  17.  
  18. // define variables
  19. $username = $_POST['username'];
  20. $password = $_POST['password'];
  21. $check_password = $_POST['check_password'];
  22. $email = $_POST['email'];
  23.  
  24. // check for empty variables, echo, then die if true.
  25. if (empty($username)) {
  26. echo "Username Blank!";
  27. }
  28. elseif (empty($password)) {
  29. echo "Password Blank!";
  30. }
  31. elseif (empty($check_password)) {
  32. echo "Check Password Blank!";
  33. }
  34. elseif (empty($email) {
  35. echo "Email Blank!";
  36. }
  37. if (empty($username) || empty($password) || empty($check_password) || empty($email)) {
  38. exit();
  39. }
  40.  
  41. // $password does not equal $check_password
  42. if ($password!=$check_password) {
  43. die("Passwords do NOT match!");
  44. }
  45.  
  46. // Echo Variables
  47. echo "Welcome" . " " . $username . "<br />";
  48. echo "Your Password" . ": " . $password . "<br />";
  49. echo "Your Email" . ": " . $email . "<br />";
  50.  
  51. // Send user an email with PHP Mail.
  52. $to = 'test@example.com';
  53. $subject = 'TEST';
  54. $message = 'Test Email upon Registration.';
  55. $headers = 'From: from@example.com' . "\r\n" .
  56. 'Reply-To: from@example.com' . "\r\n" .
  57. 'X-Mailer: PHP/' . phpversion();
  58. mail($to, $subject, $message, $headers);
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement