带电子邮件验证的注册表无法发送邮件

时间:2016-03-21 12:55:23

标签: php mysql email

我正在创建一个带有电子邮件验证的php / mysql注册表单,该代码在我的本地服务器上运行良好,并且在Cpanel上传时不执行任何操作。

<?php
include ('connection.php');
if(isset($_POST['submitform'])){
$name = trim(mysql_escape_string($_POST['name']));
$email = trim(mysql_escape_string($_POST['email']));
$passwords = trim(mysql_escape_string($_POST['pwd']));
$password = md5($passwords);
$query_verify_email = "SELECT * FROM register  WHERE email ='$email' and isactive = 1";
$result_verify_email = mysqli_query($con,$query_verify_email);
if (!$result_verify_email) {
echo ' Syste Error! ';
}
if (mysqli_num_rows($result_verify_email) == 0) { 
$hash = md5(uniqid(rand(), true))

虽然我可以连接到数据库,但似乎没有向数据库插入任何数据

$query_create_user = "INSERT INTO `register` ( `name`, `email`, `password`, `hash`) VALUES ( '$name', '$email', '$password', '$hash')";
$result_create_user = mysqli_query($con,$query_create_user);
if (!$result_create_user) {
echo 'Query Failed ';
}
if (mysqli_affected_rows($con) == 1) { 

这是应该验证和发送电子邮件的地方,并回显验证码已发送的消息,或者回显错误。我的主要问题是它无法将数据插入数据库

1 个答案:

答案 0 :(得分:0)

使用此mysqli_real_escape_string而不是mysql_escape_string

在$ hash = md5之后加分号(uniqid(rand(),true))

不推荐使用mysql

并在

$query_create_user = "INSERT INTO `register`...

`没必要

相关问题