<?php
include_once('scripts/db_access.php');
include_once('scripts/sql_statements.php');
$con = GetMyConnection();
if (!isset($_POST['txPassword'])) {
?>
<html>
<head>
<title>Mafia Vote Counter</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript" src="scripts/validation.js"></script>
<script language="javascript">
aryForm=new Array(Array("txPassword","Please Enter A Password","tx"),
Array("txPasswordMatch","Please Confirm Your Password","tx"),
Array("txPassword","Passwords Do Not Match","match","txPasswordMatch"),
Array("email","Please enter a valid email address.","em")
);
function ValidateMe(){
ret = checkValidate(aryForm);
if (ret) {
document.forms['register'].submit();
}
return ret;
}
</script>
</head>
<div id="text_header"><p>Mafia Vote Counter</p></div>
<div id="text_body">
<p><b>Register</b><br /></p>
<form method="post" action="register.php" name="register">
<p class="new_game">
Username: <input type="text" name="user_name" id="user_name"><br />
Password: <input type="password" name="txPassword" id="txPassword"> <br />
Password Again: <input type="password" name="txPasswordMatch" id="txPasswordMatch"> <br />
Email: <input type="text" name="email" id="email"><br /></p>
<input type="button" onclick="ValidateMe()" value="Create Account" /><br />
</form>
</div>
<?
//die('page not ready, sorry.');
}
else {
/*
$out = "";
$out .= $_POST['user_name']."<br>";
$out .= $_POST['txPassword']."<br>";
$out .= $_POST['email']."<br>";
if (isset($_POST['submit'])) { $out .= "submit set<br>"; }
else { $out .= "submit not set <br>";}
echo $out;
*/
$user_name = $_POST['user_name'];
$password = $_POST['txPassword'];
$email = $_POST['email'];
$user_lookup = lookup_user($user_name);
if ($user_lookup > 0) {
die('User already exists, go back and try a new username.');
}
else {
$email_lookup = lookup_email($email);
if ($email_lookup > 0) {
die('Email addready exists in the database, please refer to the email sent to you. Thank you!');
}
else {
new_user($user_name, $email, $password);
$out = "<script type='text/javascript'>alert('User $user_name added. Please log in.');window.location='index.php'</script>";
echo $out;
$msg = "Welcome to MafiaPHP!\n\nYou user account information follows:\nUsername: $user_name \nPassword: \"$password\" \n";
$msg .= "Note: your password is not retained in plaintext on our servers, we will not be able to retrieve it for you.\n\n";
$msg .= "Please log in at http://www.wundervoll.us/mafiaphp \nThank you!";
mail($email,"New User Account at MafiaPHP",$msg,"From: noreply@wundervoll.us");
}
}
}