<title>add_flight_time002_ins4.php</title>
<?php
/**
* ????????????????CSV??????????
* @param resource handle
* @param int length
* @param string delimiter
* @param string enclosure
* @return ??????????????????????FALSE??????
*/
function fgetcsv_reg (&$handle, $length = null, $d = ',', $e = '"') {
$d = preg_quote($d);
$e = preg_quote($e);
$_line = "";
while ($eof != true) {
$_line .= (empty($length) ? fgets($handle) : fgets($handle, $length));
$itemcnt = preg_match_all('/'.$e.'/', $_line, $dummy);
if ($itemcnt % 2 == 0) $eof = true;
}
$_csv_line = preg_replace('/(?:\r\n|[\r\n])?$/', $d, trim($_line));
$_csv_pattern = '/('.$e.'[^'.$e.']*(?:'.$e.$e.'[^'.$e.']*)*'.$e.'|[^'.$d.']*)'.$d.'/';
preg_match_all($_csv_pattern, $_csv_line, $_csv_matches);
$_csv_data = $_csv_matches[1];
for($_csv_i=0;$_csv_i<count($_csv_data);$_csv_i++){
$_csv_data[$_csv_i]=preg_replace('/^'.$e.'(.*)'.$e.'$/s','$1',$_csv_data[$_csv_i]);
$_csv_data[$_csv_i]=str_replace($e.$e, $e, $_csv_data[$_csv_i]);
}
return empty($_line) ? false : $_csv_data;
}
?>
</head>
<body>
<h1>add_flight_time002_ins4.php</h1>
????????<br />
<h3>???????????????????????????</h3>
<p>???????</p>
<p><strong>$flag?foreach???????</strong></p>
<h3>?????????</h3>
<form action="add_flight_time002_ins4.php" method="post">
????<input type="text" name="dep_place"><br />
????<input type="text" name="arr_place"><br />
?????<input type="text" name="dep_time"><br />
?????<input type="text" name="arr_time"><br />
?????<input type="text" name="airline" maxlength="3"><br />
<input type="reset" value="???"> <input type="submit" value="??">
</form>
<?php
//?????????????????????????????????????????
$flag=1;
foreach($_POST as $key => $f_data){
if($f_data!=""){
$flag=0;
}else{
$flag=1;
echo $key. "??????";
exit;
}
}
if($flag == 0){
$fname = 'add_flight_time002.txt';
$data1 = @fopen($fname,'a') or exit('???????????????</body></html>');
$tmp=implode(",",$_POST);
fwrite($data1,$tmp. "\r\n");
$flag=0;
}
?>
</body>
</html>