这是我的代码 http://codepad.org/NHykpcrq
我为每个位置指定了一个单独的 ID。我想要一封邮件让我知道我从该位置收到了邮件。
最佳答案
您可以在 if 语句中分配一个值(您可能希望将其更改为 switch 语句)
if ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=1') {
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing';
} elseif ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=2') {
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing 2';
} elseif ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=3') {
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing 3';
} else { //other options
$to = 'others@mysite.com';
$location = 'Some Name for this thing else';
}
$formcontent .= '\n Sent from '.$location;
您的 localhost 内容可能存在拼写错误:),另一个 idé(使其可移植)是将您要查找的内容更改为如下所示:
($_GET['id'] === 1)
等等。
编辑
一个switch包含 2 个更改的语句如下所示
switch ($_GET['id']) {
case 1:
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing';
break;
case 2:
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing 2';
break;
case 3:
$to = 'tanmay.kamath1992@gmail.com';
$location = 'Some Name for this thing 3';
break;
default:
$to = 'others@mysite.com';
$location = 'Some Name for this thing else';
break;
}
关于php - 我想接收来自特定位置的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31152999/