<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/db_connect.php');
if($_SESSION['logged_in'] == 1)
{
//REDIRECT TO HOMEPAGE
header('Location: http://cascades.exofire.net/index.php?a=fanclub' . $_SERVER['HTTP_HOST'] . '');
} else {
//BEGIN CHECKING USERNAME...
if(!$_POST['username']) die('Alert: username field was blank.');
//array of invalid characters
$junk = array('.' , ',' , '/' , '\');
//starting lenght of username
$len = strlen($_POST['username']);
//replace invalid characters
$_POST['username'] = str_replace($junk, '', $_POST['username']);
$test = $_POST['username'];
//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test) != $len) {
die('Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and NOT these: <b>. , / \</b>');
}
//Check if username already exists...
$q2 = mysql_query("SELECT * FROM `members` WHERE `username` = '".$_POST['username']."'");
$q3 = mysql_fetch_object($q2);
if($q3->username == $_POST['username']) {
die('<BR><BR>Sorry, but the username "'.$q3->username.'" is taken, please choose another.');
}
if(!$_POST['password']) {
die('Error: Password field was blank');
}
if(!$_POST['verify_password']) {
die('Error: Verify Password field was blank.');
}
if($_POST['password'] != $_POST['verify_password']) {
die('Error: The passwords do not match.');
}
if(strlen($_POST['password']) < 6 ) {
die('Error: Your password is too short. Must be 6 or more characters in length.');
}
$insert ="INSERT INTO `members` (username, user_password, user_email) VALUES ('".$_POST['username']."',
'".md5($_POST['password'])."', '".$_POST['email']."')";
$insert2 = mysql_query($insert);
if(!$insert2) die(mysql_error());
echo('Registration Successful, Welcome new member! You can now login to your new account.');
} else {
?>