Forum Moderators: coopster
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
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.