Share Pastebin
Guest
Public paste!

drew

By: a guest | Feb 9th, 2010 | Syntax: PHP | Size: 3.25 KB | Hits: 42 | Expires: Never
Copy text to clipboard
  1. <?php
  2. include_once('scripts/db_access.php');
  3. include_once('scripts/sql_statements.php');
  4. $con = GetMyConnection();
  5. if (!isset($_POST['txPassword'])) {
  6.     ?>
  7. <html>
  8.     <head>
  9.         <title>Mafia Vote Counter</title>
  10.         <link rel="stylesheet" type="text/css" href="style.css" />
  11.         <script language="javascript" src="scripts/validation.js"></script>
  12.         <script language="javascript">
  13.  
  14.  
  15.             aryForm=new Array(Array("txPassword","Please Enter A Password","tx"),
  16.             Array("txPasswordMatch","Please Confirm Your Password","tx"),
  17.             Array("txPassword","Passwords Do Not Match","match","txPasswordMatch"),
  18.             Array("email","Please enter a valid email address.","em")
  19.         );
  20.  
  21.  
  22.  
  23.             function ValidateMe(){
  24.                 ret = checkValidate(aryForm);
  25.                 if (ret) {
  26.                     document.forms['register'].submit();
  27.                 }
  28.                 return ret;
  29.             }
  30.  
  31.         </script>
  32.     </head>
  33.     <div id="text_header"><p>Mafia Vote Counter</p></div>
  34.     <div id="text_body">
  35.         <p><b>Register</b><br /></p>
  36.         <form method="post" action="register.php" name="register">
  37.             <p class="new_game">
  38.                 Username: <input type="text" name="user_name" id="user_name"><br />
  39.                 Password: <input type="password" name="txPassword" id="txPassword"> <br />
  40.                 Password Again: <input type="password" name="txPasswordMatch" id="txPasswordMatch"> <br />
  41.                 Email: <input type="text" name="email" id="email"><br /></p>
  42.             <input type="button" onclick="ValidateMe()" value="Create Account" /><br />
  43.         </form>
  44.  
  45.     </div>
  46.     <?
  47. //die('page not ready, sorry.');
  48.     }
  49.     else {
  50.         /*
  51. $out = "";
  52. $out .= $_POST['user_name']."<br>";
  53. $out .= $_POST['txPassword']."<br>";
  54. $out .= $_POST['email']."<br>";
  55. if (isset($_POST['submit'])) { $out .= "submit set<br>"; }
  56. else { $out .= "submit not set <br>";}
  57. echo $out;
  58.         */
  59.         $user_name = $_POST['user_name'];
  60.         $password = $_POST['txPassword'];
  61.         $email = $_POST['email'];
  62.         $user_lookup = lookup_user($user_name);
  63.         if ($user_lookup > 0) {
  64.             die('User already exists, go back and try a new username.');
  65.         }
  66.         else {
  67.             $email_lookup = lookup_email($email);
  68.             if ($email_lookup > 0) {
  69.                 die('Email addready exists in the database, please refer to the email sent to you. Thank you!');
  70.             }
  71.             else {
  72.                 new_user($user_name, $email, $password);
  73.                 $out = "<script type='text/javascript'>alert('User $user_name added. Please log in.');window.location='index.php'</script>";
  74.                 echo $out;
  75.                 $msg = "Welcome to MafiaPHP!\n\nYou user account information follows:\nUsername: $user_name \nPassword: \"$password\" \n";
  76.                 $msg .= "Note: your password is not retained in plaintext on our servers, we will not be able to retrieve it for you.\n\n";
  77.                 $msg .= "Please log in at http://www.wundervoll.us/mafiaphp \nThank you!";
  78.                 mail($email,"New User Account at MafiaPHP",$msg,"From: noreply@wundervoll.us");
  79.             }
  80.         }
  81. }