doudansui6650 2016-04-06 08:27
浏览 34

php POST数据为空,有或没有ajax jquery

Hi I am simply trying to post a form data to my mail.php file, but my php file doesn't get any post data. It shows blank. tried almost all stuffs but still the problem exists. here is my html form and php mail script.

<form action="assets/mail/mail.php" method="post">
  <fieldset class="clearfix" style="margin-left:10px;margin-top:10px;">
    <input name="key" type="hidden" value="AAFM">
    <p style="padding:0px;"><span class="fontawesome-user"></span>
      <input name="MasterInner_txtName" id="MasterInner_txtName" type="text" placeholder="Name" required>
    </p>
    <!-- JS because of IE support; better: placeholder="Username" -->
    <p style="padding:0px;"><span class="fontawesome-phone"></span>
      <input name="MasterInner_txtMobile" id="MasterInner_txtMobile" type="text" placeholder="Phone" required>
    </p>
    <!-- JS because of IE support; better: placeholder="Username" -->
    <p style="padding:0px;"><span class="fontawesome-envelope"></span>
      <input name="MasterInner_txtEmail" id="MasterInner_txtEmail" type="text" placeholder="Email" required>
    </p>
    <!-- JS because of IE support; better: placeholder="Username" -->
    <p style="padding:0px;"><span class="fa fa-home"></span>
      <input name="MasterInner_txtCity" id="MasterInner_txtCity" type="text" placeholder="City" required>
    </p>
    <!-- JS because of IE support; better: placeholder="Username" -->
    <p style="padding:0px;">
      <textarea name="MasterInner_txtRemarks" id="MasterInner_txtRemarks" placeholder="Remarks" required></textarea>
    </p>
    <!-- JS because of IE support; better: placeholder="Username" -->
    <p style="padding:0px;">
      <input name="MasterInner_submit" id="submitformbtn" Class="form-button" type="submit" value="Submit">
    </p>
  </fieldset>
</form>

and here is my php code

<?php
require_once('class.phpmailer.php');
include("class.smtp.php");
//date_default_timezone_set('Etc/UTC');

/*if($_SERVER["REQUEST_METHOD"] == "POST")
{*/
print_r($_POST);
echo "</br>";
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
 
//phpinfo();
echo "</br></br>";
if(isset($_POST['MasterInner_submit']))

        $name   = $_POST["MasterInner_txtName"];
        $phone  = $_POST["MasterInner_txtMobile"];
        $msg    = $_POST["MasterInner_txtRemarks"];
        $mcity  = $_POST["MasterInner_txtCity"];
        $email  = $_POST["MasterInner_txtEmail"];
        $key    =$_POST["key"];
        
echo "name=".$name;

    $subject = "Mr ".$name." has Submitted form From Website";
    $body = "Name: ".$name."
Email: ".$email."
Contact No: ".$phone."
City: ".$mcity."
ENQUIRY: ".$msg;

    $msg='<div class="alert_success" >Thanks for your queries, our team will get back to you.</div>';


    $mail = new PHPMailer;
    $mail->isSMTP();
    $mail->SMTPDebug = 0;
    //$mail->Debugoutput = 'html';
    $mail->Host = 'smtp.XYZ.com';
    $mail->Port = 25;
    $mail->SMTPSecure = '';
    $mail->SMTPAuth = true;
    $mail->Username = "sendermail@syz.com";
    $mail->Password = "*****";
    $mail->setFrom('sendermail@syz.com', 'MART');
    $mail->addAddress('mymail@gmail.com', 'SAM.');
    $mail->addBCC('xy@test.com', 'SSAM.');

    $mail->Subject = "Mr ".$name.' has Submitted form From Website';
    $mail->Body = $body;
    echo "email = ".$email;
    //if (!$mail->send()) {echo "Mailer Error: " . $mail->ErrorInfo;}
    //else {echo $msg;}
    if ($mail->send()) {echo $msg;} //header("location:index.html");}
    echo "phone = ".$phone;
//}
//}
?>

Please help

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)