Php 从CSV加载并转发到不同的URL

Php 从CSV加载并转发到不同的URL,php,forms,csv,Php,Forms,Csv,我有一个CSV文件,我必须从中读取,并且必须根据参数将用户转发到不同的页面。 乙二醇 我对如何检查这些参数感到困惑,也就是说,如果为真,我应该首先检查日期是否为真,然后转发给用户。如有任何意见,将不胜感激 我基本上要检查日期是否有效(是否过期),然后检查用户名(KATZ)。如果这两个参数为真,我必须将用户转发到www.google.com 谢谢像这样的东西怎么样: // Username $username = 'KATZ'; // Open the file. $fh = fopen('fi

我有一个CSV文件,我必须从中读取,并且必须根据参数将用户转发到不同的页面。 乙二醇

我对如何检查这些参数感到困惑,也就是说,如果为真,我应该首先检查日期是否为真,然后转发给用户。如有任何意见,将不胜感激

我基本上要检查日期是否有效(是否过期),然后检查用户名(KATZ)。如果这两个参数为真,我必须将用户转发到www.google.com


谢谢

像这样的东西怎么样:

// Username
$username = 'KATZ';

// Open the file.
$fh = fopen('file.csv', 'r')

// Loop through the data.
while ( ($data = fgetcsv($fh)) )
{
  $now = time();

  // Check that now is later (grater than) than the start date but earlier (less than) than the end date and that the username matches.
  if ( $now >= strtotime($data[0]) && $now <= strtotime($data[1]) && $username == $data[2] )
  {
    // Forward the user
    header('Location: ' . $data[3]);
    exit;
  }
}

// Close the file.
fclose($fh);
//用户名
$username='KATZ';
//打开文件。
$fh=fopen('file.csv','r')
//循环浏览数据。
而(($data=fgetcsv($fh)))
{
$now=时间();
//检查现在是否晚于(大于)开始日期但早于(小于)结束日期,以及用户名是否匹配。

如果($now>=STROTIME($data[0])&&$now,则必须首先定义一些条件。如果有多个条目满足相同条件,则只能转发一次。jeroen Hi这正是我面临的问题。我必须基本上检查日期是否有效(是否过期)然后检查用户名(KATZ)如果这两个参数为真,我必须将用户转发到www.google.com你到目前为止有什么?
// Username
$username = 'KATZ';

// Open the file.
$fh = fopen('file.csv', 'r')

// Loop through the data.
while ( ($data = fgetcsv($fh)) )
{
  $now = time();

  // Check that now is later (grater than) than the start date but earlier (less than) than the end date and that the username matches.
  if ( $now >= strtotime($data[0]) && $now <= strtotime($data[1]) && $username == $data[2] )
  {
    // Forward the user
    header('Location: ' . $data[3]);
    exit;
  }
}

// Close the file.
fclose($fh);