douque9815 2013-11-28 10:32
浏览 46

邮件发送功能未从.php客户表单调用

I am new to PHP coding. I have created a Customer form, followed by send e-mail function. When a Customer submits data (including E-Mail and password) he should receive a confirmation e-mail with User ID (same as entered E-Mail Id) and entered Password.
At this moment, with my current code, when a Customer submits the form, database gets updated, but no e-mail is send to the user. Can anyone point out what needs to be changed to ensure that send e-mail function works correctly.

<!DOCTYPE html>
<html>
    <head>
        <title>Registration Desk</title>

    </head>
    <body>   
        <div  class="form">
            <form id="contactform" action="reg_submit.php" method="post"> 
                <p class="contact"><label for="name">Name</label></p> 
                <input id="name" name="name" placeholder="First and last name" required=""   tabindex="1" type="text"> 

                <p class="contact"><label for="add">Address</label></p> 
                <textarea id="add" name="add"  style="width:85%; height:60%; margin-top:1%" required=""></textarea> 

                <fieldset>
                    <label>Birthday</label>
                    <input type="date"   name="dob" value="yyyy-mm-dd" required="">
                </fieldset>



                <label>I am</label>&nbsp;&nbsp;&nbsp;&nbsp;<br><br>


                <input type="radio" name="sex" value="male" >Male &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <input type="radio" name="sex" value="female">Female




                <p class="contact"><label for="email">Email</label></p> 
                <input id="email" name="email" class="field" placeholder="Please enter a valid emailid" required="" type="email">


                <p class="contact"><label for="password">Create a password</label></p> 
                <input type="password" id="password" name="password" required=""> 
                <p class="contact"><label for="repassword">Confirm your password</label></p> 
                <input type="password" id="repassword" name="repassword" required=""> 


                <br><br>

                <p class="contact"><label for="phone">Mobile phone</label></p> 
                <input id="phone" name="phone" placeholder="phone number" required="" type="text"> <br>
                <input class="buttom" name="submit" id="submit" tabindex="5" value="Sign me up!" type="submit">      
            </form> 
        </div>      
        </div>

    </body>
</html>
<?php
error_reporting( 0);
$connect=mysqli_connect("localhost","wbtecqoj_saltee","webuildtec1","wbtecqoj_salteegroup");
if(mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();   
}


if( $_POST["password"]!= $_POST["repassword"])
{
?>
    <script type="text/javascript">
    alert("password miss matched!!!.");
    history.back();


    </script>

<?php

}
if($_POST["name"]  &&  $_POST["add"]  &&  $_POST["phone"] &&  $_POST["email"] &&  $_POST["password"] &&  $_POST["dob"]  ) 
{
    $insert="INSERT INTO `db`.`new_user` (`id`, `name`, `add`, `contact`, `email`, `pass`, `dob`, `gender`,`code`) VALUES (NULL, '$_POST[name]', '$_POST[add]', '$_POST[phone]', '$_POST[email]', '$_POST[password]',  '$_POST[dob]', '$_POST[sex]', 'SAL1000000')";

    if(!mysqli_query($connect,$insert))
    {
        echo die('Error: ' . mysqli_error($connect));
    }
    else
    {

        $to=$_POST['email'];
        $from= "admin@wbtec.in";
        $subject="Welcome to xyz Group";


        $message="Welcome " . $_POST['name'] . "Dear Customer,
Your  Card Number is    " .$Ccode.$cookieId. " User id -" . $_POST['email'] . "Your Password -" . $_POST['password']. 
"Thanking You,
Customer Care,";
        $header = "From" .$from;

        if(isset($_POST['btnSend']))
        {
            $res = mail($to,$subject,$message,$header);
            if($res)
            {
                echo 'Message send';
            }
            else
            {
                echo 'msg not send';
            }
        }

}}
mysqli_close($connect);
?>
  • 写回答

4条回答 默认 最新

  • doumi0737 2013-11-28 10:45
    关注

    You are checking for

    if(isset($_POST['btnSend']))
    

    But your form doesn't contain an input named btnSend, you should be able to remove that if statement altogether

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等