制作一个注册网页(2)并实现自动发送邮箱

[0]接着上一次的代码,对register.php文件进行修改,在html里面嵌入php代码进行判断.

<!DOCTYPE HTMLE>
<html>
    <head>
        <title>The submission result</title>
    </head>
    <body>
        <?php if(@$_POST['name'] == ''||@$_POST['captain']==''||@$_POST['gender']==''||@$_POST['dorm']==''):?>
            <h1>You must complete all the information required. GO <a href = 'http://localhost/demo1/PHPtest.php' style = 'font-family:time'>Back</h1>
        <?php else: ?>
            <h1>your registratioin has been submitted successfully! Please wait for the result patiently</h1>
        <?php endif?>
    </body>
</html>

制作一个注册网页(2)并实现自动发送邮箱_第1张图片

[1]这部分代码让我们可以在注册成功之后自动给指定地址发送邮件,下面说一下windows下使用mail的方法:

(1)需要我们的服务器支持STMP才可以传递邮件,下载sendmail软件,然后按照网上教程配置好php.ini和sendmail.ini,注意打开error_log查看错误情况.

(2)对于sendmail要使用管理员模式运行,否则会出现错误…..stackoverflow上一个人花了两天发现这个问题….

(3)QQ的服务不好使,最好用163来发送邮件…..

总结:windows上配置这些很花时间。。。。还是快点转投linux……….

#

<!DOCTYPE HTMLE>
<html>
    <head>
        <title>The submission result</title>
    </head>
    <body>
        <?php if(@$_POST['name'] == ''||@$_POST['captain']==''||@$_POST['gender']==''||@$_POST['dorm']==''):?>
            <h1>You must complete all the information required. GO <a href = 'http://localhost/demo1/PHPtest.php' style = 'font-family:time'>Back</h1>
        <?php else:?>
            <h1>your registratioin has been submitted successfully!And a email has been sent to you</h1>
            <?php $to = '[email protected]'; $subject = 'Registration'; $body = 'This Person just registered'."\r\n". @$_POST['name']."\r\n". @$_POST['gender']."\r\n". @$_POST['captain']."\r\n". @$_POST['dorm']; $headers = 'From :[email protected]<br>'; if(mail($to,$subject,$body,$headers)) { print('send mail!'); } else { print('fail'); } ?>
        <?php endif?>
    </body>
</html>

你可能感兴趣的:(制作一个注册网页(2)并实现自动发送邮箱)