Thread: Admin Editing
View Single Post
Old 08-27-2008, 12:12 AM   #5 (permalink)
smartydebater
 
Newb Techie

Join Date: Jan 2006

Posts: 39

smartydebater

Default Re: Admin Editing

Do you have any programming experience? Basic html and css? I wouldn't recommend learning php without good knowledge of at least those. I'm going to assume you do. So you'll have to learn Php. The best place to learn it for free is at w3 schools: PHP Tutorial

To help you here are the main things you'll need to do: (Also remember that there are many free php scripts online, that you can change to fit your needs. Why waste time doing what others have already done for you?)

You'll need an html login page. If you want to have the login on every page of your site I'd recommend using the php require function inside of your html like this(but make sure you save the html file as .php then and have your server set to automatically correctly process .php files):
PHP Code:
<?php
require_once('login.php')
?>
The html for the page will just be a simple login form like this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login Form</title>
</head>

<body>
<form action="action.php" method="post">
 <p><b>Username:</b> <input type="text" name="Username" /></p>
 <p><b>Password:</b> <input type="password" name="Password" /></p>
 <p><input type="submit" /></p>
</form>
</body>
</html> 
Notice how this is using the post method. (You can also you the get method, but then the data will be stored in the url after a question mark. So you should stay away from "get" in this case.) The post method basically sends the data to global php variables.. which are in this php script action.php which the html form sends it's data to once submitted.
PHP Code:
<?php
  $username 
$_REQUEST['Username'];
  
$password $_REQUEST['Password'];
if ((
$username == "yourusername") && ($password == "yourpassword")) {
    echo 
"<html><!-- Remember to escape all apostrophes by putting a backslash before them like this: \' or \" inside of the php tags. Here's where you would put an html form that would print out the current html file inside of an input field and allow you to edit it and submit it and it would upload over the file. If you actually make it this far, than reply in the thread and ask for more specific help on uploading files. Also note that this way of doing it isn't really secure at all if you don't do it correctly because people can submit data to the php file that would do the upload by making their own html form, so you really need the php upload file to re validate the users login credentials.. So if you don't know what you're doing, it'd be better to place the admin page in a protected folder using apache (.htaccess and .htpasswd files) -->
"
;
} else {
    echo 
"<html>You entered the wrong username and/or password.</html>";
}
?>
But if you didn't want to edit the html by hand, then you'd just want to install a content mangement system. Hope this is more helpful to you than the other users.
smartydebater is offline