weixin_33736649 2017-01-07 23:03 采纳率: 0%
浏览 18

无法读取PHP中的POST值[重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/12769982/reference-what-does-this-error-mean-in-php" dir="ltr">Reference - What does this error mean in PHP?</a>
                            <span class="question-originals-answer-count">
                                (36 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2017-01-07 23:07:43Z" class="relativetime">3 years ago</span>.</div>
        </div>
    </aside>

I have a problem and just can't figure out what's the issue: In my php code I can't read any of the values included in the post request.

Even if I reduce the PHP-code to just reading the value, there comes a 500 error as response.

I inspected the POST-header: all the data is sent, so you should have access in php.

Here's the code:

$('#contactForm').submit(function (e) {

e.preventDefault();
var $form = $(this);

// check if the input is valid
if (!$form.valid()) return false;



$.ajax({
    type: 'POST',
    url: 'contact.php',
    data: $('#contactForm').serialize(),

    success: function (response) {
        $(".formSuccess").show();
        $(".formError").hide();

    },
    error: function (response) {
        $(".formSuccess").hide();
        $(".formError").show();

    }
});

});

contact.php

    <?php
$empfaenger = "info@heitech.co.at";
$betreff = "Formularnachricht";
$text = "Formularnachricht: 

";
if(isset($_POST["name1"]))
{
  $text .= "Name: ".&_POST["name1"];
}
if(isset($_POST["email1"]))
{
  $text .= "

Email: ".&_POST["email1"];
}
if(isset($_POST["message1"]))
{
  $text .= "

Nachricht: ".&_POST["message1"];
}

//$text = wordwrap($text, 70); 
mail($empfaenger, $betreff, $text);
?>

Thanks for your help! :)

</div>
  • 写回答

1条回答 默认 最新

  • 10.24 2017-01-07 23:06
    关注

    Replace &_POST -> $_POST.

    评论

    报告相同问题?

    悬赏问题

    • ¥15 关于#git#的问题,请各位专家解答!(相关搜索:开源项目)
    • ¥15 matlab处理脑电数据悬赏(时序图+预处理+频谱图)
    • ¥100 r语言多元回归模型怎么看表达式
    • ¥20 jenkins+sonarqube实现代码门禁时遇到的问题
    • ¥15 PMM 9010/30P
    • ¥15 pom文件依赖管理,未找到依赖
    • ¥15 现在后端返回给我一堆下载地址,都是一个视频切片后的,如何在uniapp安卓环境下将这些分片的视频下周并且合并成原始视频并下载到本地。
    • ¥15 Unity导出2D项目运行时图片变成马赛克
    • ¥15 关于communitytoolkit.mvvm的生成器得到的代码看起来没有被使用的问题
    • ¥15 matlab中此类型的变量不支持使用点进行索引