dongshan1396 2015-01-01 21:57
浏览 25
已采纳

邮件提醒无效

Am trying ti set a form in my contact page,where the user can send their feedback to me through mails. The problem here is am receiving the mail,but the page is not refreshing and no alert box comes...help to solve this My Php code-

 <?php
if (isset($_POST['submit']))
{
            //print_r($_POST);
$name=$_POST['name'];

$email=$_POST['email'];

$message=$_POST['message'];


$to='xyz@gmail.com';         
//$subject='Send mail using php';
//$message='This mail send using php';
$headers="From: $name";
$mail=mail($to,$name,$email,$message);
if($mail)
{
 echo'Mail send successfully';
}
else
{
 echo'Mail is not send';
}}

?>

and my form is-

    <form name="" action="" method="post" class="wpcf7-form">
<div class="row">
<div class="form-group col-xs-12 col-sm-12 col-md-6 col-lg-6">
        <label>Your Name</label><br />
<input type="text" name="name" id="name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" placeholder="Your name..." />
    </div>
<div class="form-group col-xs-12 col-sm-12 col-md-6 col-lg-6">
        <label>Phone</label><br />
        <input type="text" id="phone" name="phone" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" placeholder="Phone number..." />
    </div>
</div>
<div class="row">
<div class="form-group col-xs-12 col-sm-12 col-md-6 col-lg-12">
        <label>Email Address</label><br />
        <input type="text" id="email" name="email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email form-control" placeholder="Email Address..." />
    </div>


</div>
<div class="form-group">
    <label>Message</label><br />
    <textarea name="message" id="message" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-control"></textarea>
</div>
<input type="submit" id="submit" name="submit" value="Send Message" class="wpcf7-form-control wpcf7-submit submit_btn" />


</form>

展开全部

  • 写回答

3条回答 默认 最新

  • dpwo36915 2015-01-01 22:08
    关注

    if you want the message displayed as an alert, you can do:

    $mail = mail($to,$subject,$message,$header);
    ?>
    <script>
    alert('<?php echo $mail ? "Mail sent successfully" : "Mail was not sent" ?>');
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 java和硬件交互问题
  • ¥15 前台多人编辑时怎么让每个人保存刷新都互不干扰
  • ¥20 如何用Python删除单元格内连续出现的重复词?
  • ¥15 WangEditor嵌入到geeker-admin中,回车没有办法换行
  • ¥30 stm32f103c8t6制作万能红外遥控器
  • ¥15 有人会fastcrud写前端页面吗
  • ¥15 如何解除Uniaccess管控
  • ¥15 微信小程序跳转关联公众号
  • ¥15 Java AES 算法 加密采用24位向量报错如何处理?
  • ¥15 使用X11可以找到托盘句柄,监控到窗口点击事件但是如何在监听的同时获取托盘中应用的上下文菜单句柄