dsihangout90
New Member
- Messages
- 1
- Reaction score
- 0
- Points
- 0
Hello,
Recently I found a very easy way to create a User Member System with using PHP,HTML,XML and No MySQL. Thought it would e nice to show you,
STEP ONE: Making the Register Page.
STEP TWO: The Login
STEP THREE: The Settings Page (To change Passwords)
VERY IMPORTENT MAKE A FOLDER NAMMED "users" IF YOU DON'T NO USERS WILL BE ABLE TO LOGIN/REGISTERED. FOLDER USERS KEEPS THE LOGIN SCRIPTS THERE.
Enjoy.
---------- Post added at 11:32 PM ---------- Previous post was at 11:27 PM ----------
If theres any errors let me know and i'll fix them
Recently I found a very easy way to create a User Member System with using PHP,HTML,XML and No MySQL. Thought it would e nice to show you,
STEP ONE: Making the Register Page.
PHP:
<?php
$errors = array();
if(isset($_POST['login'])){
$username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
$email = $_POST['email'];
$password = $_POST['password'];
$c_password = $_POST['c_password'];
if(file_exists('users/' . $username . '.xml')){
$errors[] = 'Username already exists';
}
if($username == ''){
$errors[] = 'Username is blank';
}
if($email == ''){
$errors[] = 'Email is blank';
}
if($password == '' || $c_password == ''){
$errors[] = 'Passwords are blank';
}
if($password != $c_password){
$errors[] = 'Passwords do not match';
}
if(count($errors) == 0){
$xml = new SimpleXMLElement('<user></user>');
$xml->addChild('password', md5($password));
$xml->addChild('email', $email);
$xml->asXML('users/' . $username . '.xml');
header('Location: compleat.php');
die;
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<font size=1>
<form method="post" action="">
<?php
if(count($errors) > 0){
echo '<ul>';
foreach($errors as $e){
echo '<li>' . $e . '</li>';
}
echo '</ul>';
}
?>
<p>Username <input type="text" name="username" size="20" /></p>
<p>Email <input type="text" name="email" size="20" /></p>
<p>Password <input type="password" name="password" size="20" /></p>
<p>Confirm Password <input type="password" name="c_password" size="20" /></p>
<p><input type="submit" name="login" value="Register" /></p>
</form>
</body></font>
</html>
PHP:
<?php
$error = false;
if(isset($_POST['login'])){
$username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
$password = md5($_POST['password']);
if(file_exists('users/' . $username . '.xml')){
$xml = new SimpleXMLElement('users/' . $username . '.xml', 0, true);
if($password == $xml->password){
session_start();
$_SESSION['username'] = $username;
header('Location: index.php');
die;
}
}
$error = true;
}
?>
<form method="post" action="">
<p>Username <input type="text" name="username" size="20" /></p>
<p>Password <input type="password" name="password" size="20" /></p>
<?php
if($error){
echo '<p>Invalid username and/or password</p>';
}
?>
<p><input type="submit" value="Login" name="login" /></p>
</form>
PHP:
<?php
session_start();
if(!file_exists('users/' . $_SESSION['username'] . '.xml')){
header('Location: login.php');
die;
}
$error = false;
if(isset($_POST['change'])){
$old = md5($_POST['o_password']);
$new = md5($_POST['n_password']);
$c_new = md5($_POST['c_n_password']);
$xml = new SimpleXMLElement('users/' . $_SESSION['username'] . '.xml', 0, true);
if($old == $xml->password){
if($new == $c_new){
$xml->password = $new;
$xml->asXML('users/' . $_SESSION['username'] . '.xml');
header('Location: logout.php');
die;
}
}
$error = true;
}
?>
<head>
</head>
<body>
<span style='text-shadow: 1 0 0 black;'><font size=2>Change Password:</span>
<form method="post" action="">
<?php
if($error){
echo '<p><u><h6>ERROR: A Password(s) has been typed Wrong! Try Again!</u></h6></p>';
}
?>
<p>Old password <input type="password" name="o_password" size=10 /></p>
<p>New password <input type="password" name="n_password" size=10 /></p>
<p>Confirm new password <input type="password" name="c_n_password" size=10 /></p>
<p><input type="submit" name="change" value="Change Password" size=10 /></p>
</form>
<hr />
<font size=1>IP Logged on you're Account: <span style='text-shadow: 1 0 0 black;'>
<?
$ip = getenv(REMOTE_ADDR);
print "".$ip;
?></span>
Enjoy.
---------- Post added at 11:32 PM ---------- Previous post was at 11:27 PM ----------
If theres any errors let me know and i'll fix them