いちばん失敗した人決定戦

Xamppのapacheを用いて
localhostで次のプログラムを実行するとうまくいくのですが
いざレンタルサーバにアップするとうまくいきません。
(whss.bizというphp,mysql対応サーバ)

<?php
if(isset($_POST['userid'])==True && isset($_POST['password'])==True)
{
$userid=$_POST['userid'];
$password=$_POST['password'];
$logFile=dirname(__FILE__).'/'.$userid.'.log';
if(file_exists($logFile)==False)
{
file_put_contents($logFile,$password);
header("Location:backtotop.html");
}
else
{
echo '<font color="red">このユーザーIDはすでに使われています。<br>
恐れ入りますが別のIDにして下さい。</font><br>';
}
}
?>
<html>
<head>
<title>新規登録画面</title>
</head>
<body>
新規ユーザー登録を行います。<br>
好きなユーザー名とパスワードをともに半角英数字で入力してください。<br>
<form action="newuser.php" method="POST">
ユーザー名:<br>
<input type="text" name="userid" size="25" /><br />
パスワード:<br>
<input type="text" name="password" size="25">
<input type="submit" value="入力完了">
</form>
</body>
</html>

これはユーザーIDとパスワードを登録するものなのですが、
Warning: file_put_contents(/home/brightsuger/public_html/brightsuger.log) [function.file-put-contents]: failed to open stream: Permission denied in /home/brightsuger/public_html/newuser.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at /home/brightsuger/public_html/newuser.php:9) in /home/brightsuger/public_html/newuser.php on line 10

入力完了を押すと↑がでてきてしまいます。
1つ目のWarningにあるように
サーバー上ではfile_put_contentsはできないのでしょうか?
また、2つ目のWarningは意味がよくわかりません。

A 回答 (1件)

パーミッションによりファイルの作成に失敗した、ということ。

ファイルを保存するディレクトリのパーミッションを確認してみる。(書き出しが許可されているかどうか)

その後のエラーは、9行目でエラーメッセージが出力された後でheaderを出力しようとしたために「もうヘッダーは出力した後だよ」という意味で発生したものなので、9行目のエラーがなくなれば自然と消えるはず。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!