<?php

################################################
# EVILCMS FLATFILE RECODE - 100% FUNCTIONALITY #
################################################

Session_Start();

If($CMS->LoggedIn):
	Echo "Already registered.";
Else:
	If(Isset($_POST['username']) && isset($_POST['password']) && isset($_POST['cpassword']) && isset($_POST['email'])) {
		If($CMS->User_Exist($_POST['username'])) {
			Echo "Username taken.";
		}else{
			If($_POST['password'] == $_POST['cpassword']) {
				If(!$CMS->Register($_POST['username'], $_POST['password'], $_POST['email'])) {
					Echo "Registration failed.";
				}else{
					Echo "Registration suceeded.";
				}
			}else{
				Echo "Passwords doesnt match.";
			}
		}
	}else{
		Echo "<form method=\"post\" action=\"?p=register\">
		Username: <input type=\"text\" name=\"username\"><br />
		Password: <input type=\"password\" name=\"password\"><br />
		Confirm Password: <input type=\"password\" name=\"cpassword\"><br />
		Email: <input type=\"text\" name=\"email\"><br />
		<input type=\"submit\" value=\"Register\">
		</form>
		";
	}
EndIf;

?>