Jump to content

[SOLVED] Writing to Log Help


ZachEdwards

Recommended Posts

I am currently using this code:

<?php
$myFile = "orderlog.html";
$fh = fopen($myFile, 'w') or die("can't open file");<br>
$stringData = ' <HR> FirstName - '$_POST['firstname'].'<br /> LastName - '.$_POST['lastname'];
$stringData = $stringData.'<br /> ForumName - '.$_POST['forumname'].'<br /> Email - '.$_POST['email'];
$stringData = $stringData.'<br /> dobDAY - '.$_POST['dobDay'].'<br /> dobMONTH - ';
$stringData = $stringData.$_POST['dobMonth'].'<br /> dobYEAR - '.$_POST['dobYear'];
$stringData = $stringData.'<br /> High Definition - '.$_POST['chkHIDEF'];
$stringData = $stringData.'<br /> DVD Case - '.$_POST['chkDVD'];
$stringData = $stringData.'<br /> Jewel Case - '.$_POST['chkJEWEL'];
$stringData = $stringData.'<br /><br /> Where did you hear about us - '.$_POST['hearaboutus'];
$stringData = $stringData.'<br /><br /><br />';
fwrite($fh, $stringData);
fclose($fh);
echo 'Thanks for the order!';
?>

 

It is located in a file called postlog.php

 

What's wrong with it?

Everytime I post to it I get this:

 

$stringData = '  FirstName - '$_POST['firstname'].'

LastName - '.$_POST['lastname']; $stringData = '

ForumName - '.$_POST['forumname'].'

Email - '.$_POST['email'].; $stringData = $stringData.'

dobDAY - '.$_POST['dobDay'].'

dobMONTH - '; $stringData = $stringData.$_POST['dobMonth'].'

dobYEAR - '.$_POST['dobYear']; $stringData = $stringData.'

High Definition - '.$_POST['chkHIDEF']; $stringData = $stringData.'

DVD Case - '.$_POST['chkDVD']; $stringData = $stringData.'

Jewel Case - '.$_POST['chkJEWEL']; $stringData = $stringData.'

 

Where did you hear about us - '.$_POST['hearaboutus']; $stringData = $stringData.'

 

 

'; fwrite($fh, $stringData); fclose($fh); echo 'Thanks for the order!'; ?>

 

I'm a newbie to PHP

Link to comment
https://forums.phpfreaks.com/topic/86717-solved-writing-to-log-help/
Share on other sites

Try...

 

<?php

$myFile = "orderlog.html";
$fh = fopen($myFile, 'w') or die("can't open file");

$stringData = '<HR> FirstName - ' . $_POST['firstname'] . '<br /> LastName - ' . $_POST['lastname'];
$stringData .= '<br /> ForumName - ' . $_POST['forumname'] . '<br /> Email - ' . $_POST['email'].;
$stringData .= '<br /> dobDAY - '.$_POST['dobDay'].'<br /> dobMONTH - ';
$stringData .= $_POST['dobMonth'] . '<br /> dobYEAR - ' . $_POST['dobYear'];
$stringData .= '<br /> High Definition - ' . $_POST['chkHIDEF'];
$stringData .= '<br /> DVD Case - ' . $_POST['chkDVD'];
$stringData .= '<br /> Jewel Case - ' . $_POST['chkJEWEL'];
$stringData .= '<br /><br /> Where did you hear about us - ' . $_POST['hearaboutus'];
$stringData .= '<br /><br /><br />';

if (fwrite($fh, $stringData)) {
  echo 'Thanks for the order!';
} else {
  echo "failed to write to $myFile";
}
fclose($fh);

?>

Now I'm using this:

<?php
$myFile = "orderlog.html";
$fh = fopen($myFile, 'w') or die("can't open file");<br>
$stringData = '<HR> FirstName - ' . $_POST['firstname'] . '<br /> LastName - ' . $_POST['lastname'];
$stringData .= '<br /> ForumName - ' . $_POST['forumname'] . '<br /> Email - ' . $_POST['email'].;
$stringData .= '<br /> dobDAY - '.$_POST['dobDay'].'<br /> dobMONTH - ';
$stringData .= $_POST['dobMonth'] . '<br /> dobYEAR - ' . $_POST['dobYear'];
$stringData .= '<br /> High Definition - ' . $_POST['chkHIDEF'];
$stringData .= '<br /> DVD Case - ' . $_POST['chkDVD'];
$stringData .= '<br /> Jewel Case - ' . $_POST['chkJEWEL'];
$stringData .= '<br /><br /> Where did you hear about us - ' . $_POST['hearaboutus'];
$stringData .= '<br /><br /><br />';

if (fwrite($fh, $stringData)) {
  echo 'Thanks for the order!';
} else {
  echo "Failed to write to $myFile";
}
fclose($fh);

?>

 

Get the same thing.[/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.