用php实现用户的注册并且有邮箱验证

编程入门 行业动态 更新时间:2024-10-27 21:24:47

 用户的登录注册可以说是我们经常要写的一些简单代码,今天我先给大家带来用php写的用户的注册别且有邮箱的验证

<?php
require ('email.class.php');
include "dbconnect.php";
include "functions.php";
$form=check_form(@$_POST['edit']);
extract($form);


$username=@$_POST['username'];
$sql="insert into tb_user(id,username,password,mail) values(null,'".@$_POST['username']."','".@$_POST['password']."','".@$_POST['mail']."')";
mysql_query($sql);

@$sql1 = "insert into tb_user(id,username,password,status,md5name) values(null,'{$name}','{$pass}','0',md5('{$name}'))";

$res = mysql_query($sql1);
 // echo $mail;                                                                                                                                        
//echo $sql;
//$sql1="select mad5name from tb_user where username='[$name]'";
//mysql_query($sql1);
$smtpserver = "smtp.163";//SMTP服务器
$smtpserverport =25;//SMTP服务器端口
$smtpusermail = "*********发信人
@$smtpemailto = $mail;//收信人
$smtpuser = "*************"; //smtp.qq需要验证的
$smtppass = "**********";
$mailsubject = "激活码";

$mailbody = "<a href=http://localhost/do_reg.php?id=3>点击http://localhost/do_reg.php?id=3</a>";
$mailtype = "HTML";

$smtp = new smtp($smtpserver,$smtpserverport,true,$smtpuser,$smtppass);
$smtp->debug = false;
$smtp->sendmail($smtpemailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

 

//写入成功跳转到login.php

?>

<!--action="可以当前页面,也可以为另一个独立的php页面"-->

<form action="" method="post" id="user_register">

<table align="center" background="#cccccc">
<tr bgcolor="#CCCCCC"><td colspan="2"><div align="center">会员注册</div></td></tr>
 <tr bgcolor="#6699CC">
<td width="80"><div align="right">用户名:</div></td>
  <td width="378">  
  <input type="text" name="edit[name]" id="edit-name" size="30" />
     </td>
  </tr>
    <tr bgcolor="#CCCCCC">
   <td><div align="right">密 码:</div></td>
 
   <td>
   <input type="password" name="edit[pass]" id="edit-pass" size="30" />
   </td>
    <tr bgcolor="#6699CC">
<td><div align="right">确认密码:</div></td>
<td>
  <input type="password" name="edit[pass2]" id="edit-pass2" size="30" />
  </td>
  </tr>
  <tr bgcolor="#6699CC">

   <td width="45"><div align="right">邮箱:</div></td>
     <td>
         <input type="text" name="edit[mail]" id="edit-mail"/>
      </td>
  </tr>
 <tr bgcolor="#CCCCCC" align="center">
<td colspan="2">
<input type="submit" name="op" value="确认注册" οnclick="return check_form()"/>
</td>
</tr>
</table>
</form>
<script language="javascript">
function check_form(){

 var username = document.getElementById("edit-name").value;

 var password = document.getElementById("edit-pass").value;

 var password2 = document.getElementById("edit-pass2").value;

 var mail = document.getElementById("edit-mail").value; 

 var msg ="";
 if(username=="")
 {
 msg+="username is not null! \n";
  alert(msg);
    }
 if(password==""){msg+="password is not null! \n";
   alert(msg);
    }
 if(password!=password2){msg+="password must equal! \n";
   alert(msg);
 
    }
 if(radiobutton==""){msg+="sex is not null! \n";
   alert(msg);
    }
 if(mail==""){msg+="mail is not null! \n";
   alert(msg);
    }
 if(msg==""){
  alert("哈哈,小飞飞又成功了");
  window.open("login.php");
     return true;
 
    }else{
      alert("小飞飞,你终于失败了");
       return false;
          }


}

</script>

 

更多推荐

用php实现用户的注册并且有邮箱验证

本文发布于:2023-06-14 08:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455324.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:邮箱   用户   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!