Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $_POST['submit'] NOT SET
- if (!isset($_POST['submit'])) { ?>
- <form action="page.php" method="POST" >
- <span>Username: </span><input type="text" name="username" />
- <span>Password: </span><input type="text" name="password" />
- <span>Repeat ^: </span><input type="password" name="check_password" />
- <span>Email Address: </span><input type="email" name="email" />
- </form>
- <?php }
- // $_POST['submit'] SET
- if (isset($_POST['submit'])) {
- // define variables
- $username = $_POST['username'];
- $password = $_POST['password'];
- $check_password = $_POST['check_password'];
- $email = $_POST['email'];
- // check for empty variables, echo, then die if true.
- if (empty($username)) {
- echo "Username Blank!";
- }
- elseif (empty($password)) {
- echo "Password Blank!";
- }
- elseif (empty($check_password)) {
- echo "Check Password Blank!";
- }
- elseif (empty($email) {
- echo "Email Blank!";
- }
- if (empty($username) || empty($password) || empty($check_password) || empty($email)) {
- exit();
- }
- // $password does not equal $check_password
- if ($password!=$check_password) {
- die("Passwords do NOT match!");
- }
- // Echo Variables
- echo "Welcome" . " " . $username . "<br />";
- echo "Your Password" . ": " . $password . "<br />";
- echo "Your Email" . ": " . $email . "<br />";
- // Send user an email with PHP Mail.
- $to = 'test@example.com';
- $subject = 'TEST';
- $message = 'Test Email upon Registration.';
- $headers = 'From: from@example.com' . "\r\n" .
- 'Reply-To: from@example.com' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- mail($to, $subject, $message, $headers);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement