sanusart Posted May 1, 2007 Share Posted May 1, 2007 Hello, I am VERY new to php and i probably missing something stupid. I was trying to write some code to let visitor of my site to submit text information from <form> and to let that info be displayed on the same page bellow. The code is working great on my PC but it keeps erroring me on the server. I'd really appreciate if someone could check the code for a possible errors. The form (on guestbook.php page): <center> <form action="commentsdata.php" name="data" method="post"> Name:<br /> <input type="text" class="textfield" name="name" /><br /> Message:<br /> <textarea class="textarea" name="message"></textarea><br /> <input type="reset" value="Reset" /> <input type="submit" value="Post" /> </form> <p class="pack">You can use standart <i>html</i> tags in the message window.<br /> <small>(This may cause the page validation to fail).</small></p> </center> <br /> <h1><img src="arrow.gif" alt="" />The messages:</h1> <?php include ("massages.html"); ?> The form action (commentsdata.php): <?php $data = "<p><b>From:</b><br /> ".$_POST['name']."<br />"; $data = $data."<b>Message:</b><br /> ".$_POST['message']."</p><hr />"; $file = "massages.html"; if (!$file_handle = fopen($file,"a+")) { echo "Cannot open file"; } if (!fwrite($file_handle,$data)) { echo "Cannot write to file"; } echo ('<meta http-equiv="Refresh" content="0;url=posted.html" />'); fclose($file_handle); echo ('<meta http-equiv="Refresh" content="5;url=guestbook.php" />'); ?> Thank you very much, Sasha Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 1, 2007 Share Posted May 1, 2007 what error are you getting? are all files uploaded? and are the paths correct? Quote Link to comment Share on other sites More sharing options...
jitesh Posted May 1, 2007 Share Posted May 1, 2007 Write your error with line no. Quote Link to comment Share on other sites More sharing options...
sanusart Posted May 1, 2007 Author Share Posted May 1, 2007 Sorry, forgot the error: Warning: fopen(massages.html): failed to open stream: Permission denied in /home/vhosts/sanusart.com/httpdocs/commentsdata.php on line 6 Cannot open file Warning: fwrite(): supplied argument is not a valid stream resource in /home/vhosts/sanusart.com/httpdocs/commentsdata.php on line 7 Cannot write to fileSent! Warning: fclose(): supplied argument is not a valid stream resource in /home/vhosts/sanusart.com/httpdocs/commentsdata.php on line 9 All the files are uploaded and i rechecked the paths (after all it runs without problems on localhost)... and the files are chmoded to 755 so the're should be writable. Quote Link to comment Share on other sites More sharing options...
jitesh Posted May 1, 2007 Share Posted May 1, 2007 IF you need to write in a file then make chmoded to 777 Quote Link to comment Share on other sites More sharing options...
sanusart Posted May 1, 2007 Author Share Posted May 1, 2007 Thank you, i knew i did some stupid mistake! Works god now on the server too! Quote Link to comment 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.