Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有IP的CSV格式表单数据存储:未定义错误_Php_Forms_Csv_Undefined - Fatal编程技术网

Php 带有IP的CSV格式表单数据存储:未定义错误

Php 带有IP的CSV格式表单数据存储:未定义错误,php,forms,csv,undefined,Php,Forms,Csv,Undefined,我正在尝试从访问者那里获取电子邮件、国家和IP地址,并将其存储到CSV中,还将向网站所有者发送电子邮件 我不太熟悉,但我得到了大多数东西的作品,但无法摆脱未定义的错误为$cvsData.=“\“$email\”,“$ip\”.PHP\u EOL行 错误消息:注意:未定义索引:中的ip\U地址 这是我的密码 <?php // this is to store form into csv file if(isset($_POST["submit"])) {

我正在尝试从访问者那里获取电子邮件、国家和IP地址,并将其存储到CSV中,还将向网站所有者发送电子邮件

我不太熟悉,但我得到了大多数东西的作品,但无法摆脱未定义的错误为
$cvsData.=“\“$email\”,“$ip\”.PHP\u EOL

错误消息:注意:未定义索引:中的ip\U地址

这是我的密码

<?php

// this is to store form into csv file
    if(isset($_POST["submit"]))
    {   
        $email = $_POST["email"];
        $ip = $_SERVER['REMOTE_ADDR'];


        if(empty($email))
        {
            echo "ERROR MESSAGE";
            die;
        }
        $cvsData .= "\"$email\",\"$ip\"".PHP_EOL;
        $fp = fopen("emails.csv", "a");

        if($fp)
        {
            fwrite($fp,$cvsData); // Write information to the file
            fclose($fp); // Close the file
            echo "<h3>Thank you! we will inform you.....</h3>";
        }    

    }

// this is to send email to site owner

    // Contact subject
    $email ="$email";
    // Enter your email address
    $to ='myemail@site.com';

    $subject ='site Email Submited';

    $send_email=mail($to,$email,$subject);

    // Check, if message sent to your email
    // display message "We've recived your information"
    if($send_email){
        echo "Email address is sent to the department.";
    } else {
        echo "ERROR";
    }

?> 
错误不在您粘贴的代码中,因为未提及
ip\U地址