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";
}
?>
表只有一個字段名稱=「電子郵件」,並提交按鈕