0
我试图从访问者处获取电子邮件,国家和IP地址并将其存储到CSV中,并且还会向该站点所有者发送电子邮件。使用IP以CSV格式存储数据存储:未定义错误
我没有太多熟悉的,但我得到了大多数事情的作品,但没能摆脱掉未定义错误$cvsData .= "\"$email\",\"$ip\"".PHP_EOL;
线...
Error Message: Notice: Undefined index: ip_address in
这里是我的代码
<?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 ='[email protected]';
$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";
}
?>
表只有一个字段名称=“电子邮件”,并提交按钮