16c02-1.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 37 行
PHP
37 行
<?php// If we had a POST element called 'email', then we need to prep and send:if (isset($_POST['email'])) { // Make sure it wasn't blank: $email = trim($_POST['email']); if ($email) { // Prepare by setting a timezone, mail() uses this. date_default_timezone_set('America/New_York'); // Take the address given, prepend a magic string, and hash it: $hashed = md5('magic_string' . $email); // Make the email address ready to be sent via, well, email: $prepped = urlencode($email); // Generate the email message that these people need to verify: // For simplicity, doing this as pure text email at this point. mail($email, 'Please verify your email address', "Someone has entered your email address into our form.If it was you, and you wish to verify your address, please click the following link:http://example.com/verify.php?e={$prepped}&h={$hashed}", 'From: php@example.com'); // Let them know that this email is sent. echo "<p>A verification email has been sent to {$email}, please following the instructions included in it.</p>"; }}?><form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="f1"><p>What is your email address? <input name="email" type="text" /></p><p><input type="submit" /></p></form>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?