如何在PHP上验证新用户的帐户?

时间:2014-11-17 18:59:41

标签: php mysql

我在项目中使用PHP。如何提示新用户输入他们的电子邮件地址,以便我可以向他们发送验证链接?

1 个答案:

答案 0 :(得分:1)

你可以像这样编写一个简单的表单html:

form.html:

  <form action="submit.php" method="post">
      <input type="email" name='email'>
      <input type="submit" name="submit" value="send">
  </form>

submit.php:

   <?php

       if(isset($_POST['submit']) && !empty($_POST['email'] )){
          $email = $_POST['email'];
          // you've got the email so far , you can do what ever you want with it 
         // for example : you can send email or ...

         $to      = $email;
         $subject = 'the subject';
         $message = 'hello';
         $headers = 'From: webmaster@example.com' . "\r\n" .
             'Reply-To: webmaster@example.com' . "\r\n" .
             'X-Mailer: PHP/' . phpversion();

         mail($to, $subject, $message, $headers);

       }else{

           echo "You can go fuzz yourself :D";
     }

    ?>

这不安全,也不是发送电子邮件的强大方式,我只是想给你提示,所以一定要检查用户输入等等......