if you know HTML, this should do it:
copy and paste the following code into a file called 'login.php':
//------BEGIN CODE---------
<?php
include("turtle.inc.php");
foreach($_POST as $value){
$value=stripslashes($value);
$value=mysql_escape_string($value);}
$db=mysql_connect("localhost", "$turtleusername", "$turtlepassword") or die ('SQL error: ' . mysql_error());
mysql_select_db ("turtlebase");
$querystring = "select username,password from users where username=$_POST[username] and password=$_POST[password] limit 1";
$query=mysql_query($querystring);
$myrow=mysql_fetch_assoc($query);
if(count($myrow)>0){
session_start();
$_SESSION[status]="logged";
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>Redirecting...</title>
<meta http-equiv=\"refresh\" CONTENT=0;URL=$tfirstpage>
</head><body></body></html>";
}else{die("improper login");}?>
//------END CODE------------
then make a file called 'install.php' with contents:
//----------BEGIN CODE----------
<?php
include("turtle.inc.php");
$db=mysql_connect("localhost", "$turtleusername", "$turtlepassword") or die ('SQL error: ' . mysql_error());
mysql_create_db("turtlebase");
mysql_select_db ("turtlebase");
$querystring = "select username,password from users where username=$_POST[username] and password=$_POST[password] limit 1";
$query=mysql_query("CREATE TABLE users (username VARCHAR(30) NOT NULL,password VARCHAR(30) NOT NULL)");
include("./index.html"};?>
//----------END CODE------------------------
rename every single MEMBERS' (ie, you should still have an index.html) page EXTENSION from htm or html to php. It won't futz with your layout...php is cool like that.
add the following line to every member's page at the VERY TOP of each MEMBERS' PAGE:
//-----BEGIN CODE------------
<?php session_start(); if($_SESSION[status]=="logged"){ ?>
//------END CODE-------------
add the following line to the very BOTTOM of every MEMBERS' page:
//---------BEGIN CODE--------
<?php }else{die("You are not logged in");} ?>
//------END CODE--------------
now make a file called 'turtle.inc.php' and paste the following code, filling in the necessary fields:
//------------BEGIN CODE-------------
<?php
$turtleusername="<USERNAME>"; // This is the name of a user for the mysql on your host
$turtlepassword="<PASSWORD>"; //This is the password for the user above
$tfirstpage="<FIRSTPAGE>"; /*This is the FIRST page a member should see after logging in. follow same convention as src attribute...like src=./filename.ext for current dir or ../filename.ext for parent dir...etc.*/
?>
//------------END CODE----------------
create a file called 'adduser.php' with the following:
//-----------BEING CODE-------------
<?php
include("turtle.inc.php");
if(isset($_POST[username]) && isset($_POST[password]))
{
$db=mysql_connect("localhost", "$turtleusername", "$turtlepassword") or die ('SQL error: ' . mysql_error());
mysql_select_db ("turtlebase");
$query=mysql_query("insert into users(username,password) values($_POST[username],$_POST[password])");
}
?>
<html><head><title>Adduser</title></head><body><form action=./adduser.php method=post>
username: <input type=text name=username>
password: <input type=text name=password>
<input type=submit></form>
</body></html>
//-----------END CODE-------------
now follow these instructions:
-make sure that ALL your site's pages are in the root of your site(same dir/folder that your index.html goes)
-double check the values in the file turtle.inc.php for correctness.
-double check that you modified all member pages
-copy all the files you just created into the root of your site.
-Move the old copies of your member's pages somewhere else...preferably off server but another folder would prolly work too.
-you should have a login.php, adduser.php, install.php, turtle.inc.php, your non-member pages with an htm or html or whatever extension they originally had, all your member's pages with a .php extension and the modifications from above.
-in a browser, type "
http://yourdomain.com/install.php"
-your login should just be a form that you can put on ANY of your non-member pages that does the following:
it passes 2 pieces of data named "username" and "password" to the script called "login.php" using the post method.
-to add users to your site, goto "
http://yourdomain.com/adduser.php"...there should be a self explanatory form there.
-just like your mom taught you, take adduser.php off the server when you don't need it.
-sorry this is so crude, but I'm on a public terminal that has a browser and word...so if anyone on ATOT sees a typo or goof, feel free to hack it off.