PhpSnip.com

User Stats

Membership Site V1.1

A Membership section for your website. It still needs the signup section. If you have any problems... shane@mics.co.za

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 195

Source Code ( 168 lines )

#index.php

<?
#Membership Site V1.1
#This is a secure login form agains't a MySQL database
#Written by Shane James(flipside)
#mailto shane@mics.co.za

#This is the Config of the main login file
# Location of the authentification file
$authfile = "/usr/home/ccn/public_html/authenticate.php";
#End config

#This checks if the form has been submited by the form yet
if ($auth != "authenticate"){
echo "<form method=post action=index.php>";
echo "Written by Shane James(flipside)<br>";
echo "Secure log in against an encrypted MySQL database<br><br>";
echo "Membership Site V1.1<br>";
echo "<li>Created More Accurate Error Messages</li>";
echo "<li>Fixed login Bug</li>";
echo "<li>Fixed Session Bug</li><br><br>";
echo "Login: test<br>";
echo "Password: testpass";
echo "<table>";
echo "<tr><td>Login :</td><td> <input type=text name=username></td></tr>";
echo "<tr><td>Password :</td><td> <input type=text name=password></td></tr></table>";
echo "<input type=hidden name=auth value=authenticate>";
echo "<div align=left><input type=submit value="Log In"></div>";
echo "</form>";
}

#This does the secure authentication
if ($auth == "authenticate"){
require("$authfile");
if ($username != "$realuser"){
echo "Username <b>$username</b> does not excist";
}
if($username == ""){
echo "Please fill in a username";
}
if($password == ""){
echo "<br>Please fill in your password";
}
elseif ($username == "$realuser"){
if ($confirmpass == "1"){
session_start();
session_register(loggedin);
$loggedin = "98127398abasdfiu98123nius";
$PHPSESSID = session_id();
$SID = session_id();
echo "<head>";
echo "<META HTTP-EQUIV="Refresh" CONTENT="0;URL=member/index.php?SID=$SID">";
echo "</head>";
}
else {
echo "<br>Wrong password";
}
}
}

?>

#authenticate.php

<?
#Membership Site V1.1
#This is a secure login form agains't a MySQL database
#Written by Shane James(flipside)
#mailto shane@mics.co.za

#This is the authentification function

#Mysql Configfile Location
$mysqlconfigfile = "mysql.php";

require('/usr/home/ccn/public_html/mysql.php');
$authenticateuser = "select * from $db_name where username = '$username'";
mysql_connect("$db_host", "$db_user", "$db_pass");
$result = mysql_db_query("$db_name", $authenticateuser); 
while ($row = mysql_fetch_array($result)){
$realuser = $row["username"];
}

$authenticatepass = "select * from $db_name where password = password('$password') and username = '$username'";
$query = mysql_query($authenticatepass);
$confirmpass = mysql_numrows($query);
?>

#mysql.php

<?
#Membership Site V1.1
#This is a secure login form agains't a MySQL database
#Written by Shane James(flipside)
#mailto shane@mics.co.za

#This is the MySQL config file

#Database Hostname
$db_host = "localhost";

#Database Username
$db_user = "mics";

#Database Password
$db_pass = "mics012";

#Database Name
$db_name = "mics";
?>

#logout/index.php

<?
#Membership Site V1.1
#This is a secure login form agains't a MySQL database
#Written by Shane James(flipside)
#mailto shane@mics.co.za

session_start();

session_unset();

session_destroy();

echo "you've just loged out!";
?>

#member/index.php

<?
#Membership Site V1.1
#This is a secure login form agains't a MySQL database
#Written by Shane James(flipside)
#mailto shane@mics.co.za

#This is the actual members page

session_start();
if($loggedin == "98127398abasdfiu98123nius"){
session_start();
if($SID == $PHPSESSID){
echo "If you can see this page, you've logged in correctly";
echo "<br><a href=../logout/index.php?logout=logout>click here to log out</a>";
}
#session_start();
#if($loggedin != "98127398abasdfiu98123nius"){
#echo "You are not currently logged in...please log in";
#}
else{
echo "You do not seem to be logged in correctly, Please login";
session_start();

session_unset();

session_destroy();
}
}
else {
echo "You do not seem to be logged in correctly, Please login";
session_start();

session_unset();

session_destroy();
}
?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise