ZachEdwards Posted January 19, 2008 Share Posted January 19, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/86717-solved-writing-to-log-help/ Share on other sites More sharing options...
trq Posted January 19, 2008 Share Posted January 19, 2008 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/86717-solved-writing-to-log-help/#findComment-443168 Share on other sites More sharing options...
ZachEdwards Posted January 19, 2008 Author Share Posted January 19, 2008 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] Quote Link to comment https://forums.phpfreaks.com/topic/86717-solved-writing-to-log-help/#findComment-443171 Share on other sites More sharing options...
ZachEdwards Posted January 19, 2008 Author Share Posted January 19, 2008 Just noticed: $fh = fopen($myFile, 'a') or die("can't open file");< br > Quote Link to comment https://forums.phpfreaks.com/topic/86717-solved-writing-to-log-help/#findComment-443186 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.