开发者社区> 问答> 正文

PHP注意:未定义的索引:第2行/path/to/file.php中的名称[重复]


但是,我在每个变量的每一行上都得到未定义的索引错误。

PHP Notice:  Undefined index: name in /path/to/file.php on line 2

形式:https://jsfiddle.net/dg1ur9fc/

PHP:

<?php
/* Error Reporting */
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if(isset($_POST)){
    $name   = $_POST['fullname'];
    $number = $_POST['number'];
    $email  = $_POST['email'];
    $brand  = $_POST['brand'];
    $model  = $_POST['model'];
    $variant = $_POST['variant'];
    $screen = $_POST['screen'];
    $body = $_POST['body'];
    $power = $_POST['power'];
    $battery = $_POST['battery'];
    $charge = $_POST['charge'];
    $calls = $_POST['calls'];
    $fcamera = $_POST['fcamera'];
    $rcamera = $_POST['rcamera'];
    $water = $_POST['water'];
    $wifi = $_POST['wifi'];
    $formcontent = "From: $name \n Contact: $number \n Device Brand: $brand \n Device Model: $model \n Device Variant: $variant \n Screen: $screen \n Housing: $body \n Is your device able to power on? $power \n Does your device have a fault battery? $battery \n Is your device able to charge? $charge \n Does your front camera work? $fcamera \n Does your rear camera work? $rcamera \n Is your device water damaged? $water \n Is your device able to connect using WiFi? $wifi";
    $recipient = "test@example.com";
    $subject = "Buyback Request";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader);
    /* Redirect browser */
    header("Location: https://example.com");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
}
?>
请问这个问题是什么以及如何解决?谢谢。

展开
收起
社区秘书 2019-12-09 15:57:12 475 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-深入浅出网络编程与swoole内核-吴镇宇 立即下载
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载