Forum Moderators: coopster
Maybe you could use that to get something going then if you get stuck on some of the details you could come back here with a specific problem.
$cvsfle1 = "../mail_1.txt";
$cvsfle2 = "../mail_2.txt";
$opnfle1 = fopen($cvsfle1, "r"); // Opens the csv file
$opnfle2 = fopen($cvsfle2,'w');
while ($usrinfo = fscanf($opnfle, "%s %s\t%s\t%s\t%s\n")){
list ($fnme, $lnme, $usrnm, $emladdr, $server) = $usrinfo;
$test = str_replace($_POST["fnme"]." ".$_POST["lnme"]." ".$usrnme." ".$_POST["emladdr"]." ".$_POST["server"]."\r", $rplcmnt, $fnme." ".$lnme." ".$usrnm." ".$emladdr." ".$server."\r");
fwrite($opnfle2,$test);
}
What I need to know is whats the best way to go about over writing the data in $cvsfle1. Would you make sure you have the data written to $cvsfle2 then delete $cvsfle1 and rename $cvsfle2. Or is there a better way? Thanks
fintan.
$msearch = $_POST["msearch"];$x=0;
print( "\n\n <h3>Matches found:</h3>" );
print( "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n" );
while ($usrinfo = fscanf($opnfle, "%s %s\t%s\t%s\t%s\n")){
list ($fnme, $lnme, $usrnm, $emladdr, $server) = $usrinfo;
$all = $fnme." ".$lnme." ".$usrnm." ".$emladdr." ".$server;
if(preg_match("/\b$msearch\b/i", $all)){
print( "<tr><td>".$fnme." ".$lnme."</td>\n" );
print( "<td>".$usrnm."\n</td>\n" );
print( "<td>".$emladdr."</td>\n" );
print( "<td>".$server."</td><td>");
print( "<form name=\"form".$x++."\" method=\"post\" action=\"delete.php\">" );
print( "<input name=\"fnme\" type=\"hidden\" value=\"".$fnme."\">" );
print( "<input name=\"lnme\" type=\"hidden\" value=\"".$lnme."\">" );
print( "<input name=\"usrnm\" type=\"hidden\" value=\"".$usrnm."\">" );
print( "<input name=\"emladdr\" type=\"hidden\" value=\"".$emladdr."\">" );
print( "<input name=\"server\" type=\"hidden\" value=\"".$server."\">" );
print( "<input type=\"submit\" name=\"mdel\" value=\"Delete\"></form></td></tr>\n" );
}
else{
exit("Sorry no matches found for $msearch");
}
}
print ("</table>");