Jump to content

write information on two separate files?


digitalLotus

Recommended Posts

I'd like to know how I can have information written on two separate files after filling out a form.

Right now it works fine with one file, shown in this code:

$out = fopen("saved_data.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<tr><td class=\"col01\">$name</td><td class=\"col02\">$gender</td><td class=\"col03\">$stat</td><td class=\"col04\">$country</td><td class=\"col05\">$city</td><td class=\"col06\">$sponsors</td><td class=\"col07\">$giant | $special | $tight</td></tr>");
fclose($out);
}

 

However, there's certain information I'd like to have on another txt file.

 

Again, thanks in advance.

Cheers :)

Link to comment
https://forums.phpfreaks.com/topic/47643-write-information-on-two-separate-files/
Share on other sites

ummm???

 

<?php 
$out = fopen("saved_data.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<tr><td class=\"col01\">$name</td><td class=\"col02\">$gender</td><td class=\"col03\">$stat</td><td class=\"col04\">$country</td><td class=\"col05\">$city</td><td class=\"col06\">$sponsors</td><td class=\"col07\">$giant | $special | $tight</td></tr>");
fclose($out);
}

$out = fopen("saved_data2.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"write other data here");
fclose($out);
}
?>

 

???

Here's the complete code of the test file.

As soon as I add the part for the second file, it doesn't work anymore.

 

<?php

session_start();

$name = $_GET['name'];
$day = $_GET['dd'];
$month = $_GET['mm'];
$year = $_GET['yyyy'];
$gender = $_GET['gender'];
$stat = $_GET['stat'];
$country = $_GET['country'];
$city = $_GET['city'];
$sponsors = $_GET['sponsors'];
$mail = $_GET['mail'];
$giant = $_GET['giant'];
$special = $_GET['special']; 
$tight = $_GET['tight']; 

$random = trim($_GET['random']);

if ($_SESSION['new_string'] == $random){
echo "Thank you for signing up.";
$out = fopen("saved_data.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<tr><td class=\"col01\">$name</td><td class=\"col02\">$gender</td><td class=\"col03\">$stat</td><td class=\"col04\">$country</td><td class=\"col05\">$city</td><td class=\"col06\">$sponsors</td><td class=\"col07\">$giant | $special | $tight</td></tr>");
fclose($out);
}
else{
echo "Please reenter the code.";
}?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.