Forum Moderators: coopster

Message Too Old, No Replies

Web Log

         

traffik daddy

11:32 am on Aug 27, 2003 (gmt 0)

10+ Year Member



Hi,

I'm having a little trouble creating a Web Log and would be greatful for a little advice.

Here is the first bit of code which I use to check the user login:


<?php
if ($user!="password"){
header("location: declined.html");
exit;
}
?>

I edited 'password' and I have made sure that I am typing the right password in but it still directs me to Access Declined page.

I created a blank blog.html page where everything is written to and created a write_blog.php page which is as follows:


<?php
$filename="blog.html";
$oldfile=fopen($filename, "r");
$file_content=fread($oldfile, filesize($filename);
fclose($oldfile);

$date=(date("d-m-Y"));
$time=(date("H:i:s"));

$f=fopen($filename, "w+");

fwrite($f, "<table width=\"600\" border=\"0\" cellspacing=\"5\" cellpadding=\"2\"><tr>\r\n");

fwrite($f, "<td width=\"450\" bgcolor=\"#A20007\"><font color=\"#FFF45F\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">$title</font></td>\r\n");

fwrite($f, "<td width=\"150\" bgcolor=\"#A20007\"><font color=\"#FFF45F\" size=\"2\" face=\"Arial, Helvetica, sans-serif\">$date at $time</font></td>\r\n");

fwrite($f, "</tr><tr>\r\n");

fwrite($f, "<td colspan=\"2\"><font size=\"2\" face=\"Arial, Helvetica, sans-serif\">$entry</font></td>\r\n");

fwrite($f, "</tr></table>\r\n");

fwrite($f, "<br>\r\n");

fwrite($f, "$file_content\r\n");

fclose($f);

?>

This is the scrit used to write to my blog.html page. Can anyone see anything wrong with it?

Finally I created an index.php page and inserted

<?php include ("blog.html");?>

Now everthing is fine as far as I can see and have followed the instruction to a tee and re-read everything over and over. I set the permissions of blog.html to chmod777 so the PHP can write to it. I uploaded to my php supported hosts and cannot get the darn thing to work :(

Is there something I am missing?

Thanks in advance

Terry

panic

7:28 pm on Aug 27, 2003 (gmt 0)

10+ Year Member



Is your script outputting anything into blog.html?

-panic

jatar_k

9:01 pm on Aug 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if ($user!="password"){

Is that right? Are you using the variable $user to store the password? I would expect something like this

if ($pass!="password" ¦¦ $user!="username"){

WebmasterWorld breaks the pipe character, remember to replace with a true unbroken pipe

traffik daddy

8:53 am on Aug 28, 2003 (gmt 0)

10+ Year Member



Jatar_k,

I will try that, thanks.

Panic, nothing is getting wrote to blog.html.

Thanks for the replys, I'll let you know of any developments.

Terry

jatar_k

2:04 pm on Aug 28, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I would try two things actually. The writing to file and the login are two seperate actions and can be tested and corrected seperately.

You can remove the login check all together to test the writing to file etc.

For the login, the variables that you test for need to match the form element names from your login form. The line that I used was just a generic example. It just seems strange that the variable name for the password is called user.

panic

4:38 pm on Aug 28, 2003 (gmt 0)

10+ Year Member



Try this to see what happens...

$content = "This is the content that's going to go in blog.html";
$fp = file("blog.html","w");
fputs($fp, $content);
fclose($fp);

It's really not my place to say, but you might be better off using a database lik MySQL.

-p