我制作了一个用于Android设备的工作注册脚本。唯一剩下的就是向欢迎他的用户发送电子邮件,即“欢迎使用该应用......”等等。但是,由于没有发送电子邮件,我对此感到困惑。
这是我的剧本。
<?php
require "init.php";
header('Content-type: application/json');
$email = $_POST['email'];
$user_name = $_POST['user_name'];
$user_pass = $_POST['user_pass'];
$msg = "Congratulations. You are now registered to the most amazing app
ever!";
$passwordEncrypted = sha1($user_pass);
if($email && $user_name && $user_pass){
$sql_query = "select * from user_info WHERE email ='".mysqli_real_escape_string($con, $email)."' and user_name ='".mysqli_real_escape_string($con, $user_name)."'";
$result = mysqli_query($con, $sql_query);
$results = mysqli_num_rows($result);
if ($results){
$don = array('result' =>"fail","message"=>"Email or username exists.");
}else{
$sql_query = "insert into user_info values('$email','$user_name','$passwordEncrypted');";
if(mysqli_query($con,$sql_query)){
$don = array('result' =>"success","message"=>"Successfully registered!Well done");
mail("$email","Well done",$msg);
}
}
} if(!$email || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
$don = array('result' =>"fail","message"=>"Please enter a valid email");
}else if(!$user_name){
$don = array('result' =>"fail","message"=>"Please enter your username");
}else if(!$user_pass || (strlen($user_pass)<8 || (!preg_match('`[A-Za-z0-9]`', $user_pass)))){
$don = array('result' =>"fail","message"=>"Password must contain 8 letters or more with at least one capital letter ");
}
echo json_encode($don);
?>
关于那个的任何想法?
感谢。
答案 0 :(得分:2)
您的$email
变量不应该在引号("$email")
中,它应该是这样的 -
改变这个 -
mail("$email","Well done",$msg);
到此 -
mail($email,"Well done",$msg);