Jump to content

[SOLVED] Works on PC but error on the server.


sanusart

Recommended Posts

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.