daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Sep 4th, 2018 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. /***************************************************************************
  3.  *      WebDB/beta_scripts/signup/index.php
  4.  *                            -------------------
  5.  *      begin                : Sunday, 12 November 2006
  6.  *      copyright            : (C) 2007 Andrew W. Pong (Hakaslak)
  7.  *      email                : hakaslak@gmail.com
  8.  *
  9.  ***************************************************************************/
  10.  
  11. require_once($_SERVER['DOCUMENT_ROOT'] . '/files/includes/global.php');
  12. $error_message_sent = "";
  13. if (isset($_POST['signup_submit']))
  14. {
  15.     $register_username = varclean($_POST['register_username']);
  16.     $register_email_1 = varclean($_POST['register_email_1']);
  17.     $register_email_2 = varclean($_POST['register_email_2']);
  18.     $register_ip = getenv("REMOTE_ADDR");
  19.     $register_group = 1;
  20.  
  21.     $sent_username = ('&sent_username=' . $register_username);
  22.     $sent_email_1 = ('&sent_email_1=' . $register_email_1);
  23.     $sent_email_2 = ('&sent_email_2=' . $register_email_2);
  24.  
  25.     $check_username_availability = mysql_query("SELECT * FROM cms_users WHERE (user_username='$register_username')");
  26.  
  27.     if (($_POST['register_username'] == '') || ($_POST['register_email_1'] == '') || ($_POST['register_email_2'] == ''))
  28.     {
  29.         unset($_POST['signup_submit']);
  30.         $error_message_send = 9; // Some fields are missing.
  31.         header('Location: ' . ($_SERVER['PHP_SELF']) . '?error_msg=' . $error_message_send . $sent_username . $sent_email_1 . $sent_email_2);
  32.     }
  33.     else
  34.     {
  35.         if (mysql_num_rows($check_username_availability) == 0) // Make sure the username is available.
  36.         {
  37.             if ($register_email_1 == $register_email_2) // Make sure the emails match.
  38.             {
  39.                 if (validate_email($register_email_1)) // Make sure the email is valid syntactically.
  40.                 {
  41.                     $check_email_availability = mysql_query("SELECT * FROM cms_users WHERE (user_email='$register_email_1')");
  42.                     if (mysql_num_rows($check_email_availability) == 0) // Make sure the email has not been registered.
  43.                     {
  44.                         $display_password = substr(md5(time()),0,6);
  45.                         $insert_password = md5($display_password);
  46.                         // If all is well we dump everything into the database...
  47.                         $register_username = (mysql_escape_string($register_username));
  48.                         $insert_password = (mysql_escape_string($insert_password));
  49.                         $register_email_1 = (mysql_escape_string($register_email_1));
  50.                         $register_group = (mysql_escape_string($register_group));
  51.                         $register_ip = (mysql_escape_string($register_ip));
  52.                         $register_user_information = "
  53.                         INSERT INTO cms_users (user_username, user_password, user_email, user_group, user_ip)
  54.                         VALUES ('$register_username', '$insert_password', '$register_email_1', '$register_group', '$register_ip')";
  55.                         mysql_query($register_user_information) or die('The server made a boo boo! Not your fault!');
  56.                         require_once($_SERVER['DOCUMENT_ROOT'] . '/files/includes/mailer.php');
  57.                         if(mail($register_email_1, $subject, $message, $from))
  58.                         {
  59.                             unset($_POST['signup_submit']);
  60.                             header('Location: ' . $current_domain . 'signup/success.php?' . $sent_username . $sent_email_1);
  61.                         }
  62.                         else
  63.                         {
  64.                             echo 'Could not send email... darn...';
  65.                         }
  66.                     }
  67.                     else
  68.                     {
  69.                         unset($_POST['signup_submit']);
  70.                         $error_message_send = 3; // Email is taken
  71.                         header('Location: ' . ($_SERVER['PHP_SELF']) . '?error_msg=' . $error_message_send . $sent_username . $sent_email_problem);
  72.                     }
  73.                 }
  74.                 else
  75.                 {
  76.                     unset($_POST['signup_submit']);
  77.                     $error_message_send = 2; // Email_1 is invalid
  78.                     header('Location: ' . ($_SERVER['PHP_SELF']) . '?error_msg=' . $error_message_send . $sent_username . $sent_email_problem);
  79.                 }
  80.             }
  81.             else
  82.             {
  83.                 unset($_POST['signup_submit']);
  84.                 $error_message_send = 1; // Emails do not match
  85.                 header('Location: ' . ($_SERVER['PHP_SELF']) . '?error_msg=' . $error_message_send . $sent_username);
  86.             }// end of email / password check
  87.         }
  88.         else
  89.         {
  90.             unset($_POST['signup_submit']);
  91.             $error_message_send = 7; // Username Taken
  92.             header('Location: ' . ($_SERVER['PHP_SELF']) . '?error_msg=' . $error_message_send . $sent_username . $sent_email_1 . $sent_email_2);
  93.         }//End of the ifelse
  94.     }//End of check for blank fields
  95. }// end of isset
  96. else
  97. {
  98. require_once($_SERVER['DOCUMENT_ROOT'] . '/files/includes/global.php');
  99. require_once($_SERVER['DOCUMENT_ROOT'] . '/files/includes/header.php');
  100. ?>
  101. <h2>You need a real email!</h2>
  102. <form method="post" action="<?=($_SERVER['PHP_SELF']); ?>">
  103. <table summary="<?=$current_domain_plain?> account registration form. Single column, seperate row for each type of information." width="100%" id="register" cellspacing="0" cellpadding="10" >
  104.     <caption>Sign up for a <strong>free</strong> <?=$current_domain_plain?> account!</caption>
  105.     <tr>
  106.     <td>
  107.     <label for="register_username">Desired username:</label>
  108.     <br />
  109.     <input type="text" name="register_username" id="register_username" value="<? $register_username_sent = ""; if (isset($_GET['sent_username'])){echo (htmlspecialchars($_GET['sent_username']));}?>"/><? if (!isset($_GET['sent_username'])){echo ('<span style="color:red;font-size:large"> &#171;</span>');}?>
  110.     </td>
  111.     </tr>
  112.     <tr>
  113.     <td>
  114.     <label for="register_email_1">Email:</label>
  115.     <br />
  116.     <input type="text" name="register_email_1" id="register_email_1" value="<? $register_email_1_sent = ""; if (isset($_GET['sent_email_1'])){echo (htmlspecialchars($_GET['sent_email_1']));}?>"/><? if (!isset($_GET['sent_email_1'])){echo ('<span style="color:red;font-size:large"> &#171;</span>');}?>
  117.     </td>
  118.     </tr>
  119.     <tr>
  120.     <td>
  121.     <label for="register_email_2">Re-enter email:</label>
  122.     <br />
  123.     <input type="text" name="register_email_2" id="register_email_2" value="<? $register_email_2_sent = ""; if (isset($_GET['sent_email_2'])){echo (htmlspecialchars($_GET['sent_email_2']));}?>"/><? if (!isset($_GET['sent_email_2'])){echo ('<span style="color:red;font-size:large"> &#171;</span>');}?>
  124.     </td>
  125.     </tr>
  126.     <tr>
  127.     <td>
  128.     <input type="submit" name="Submit" id="Submit" value="Submit" />
  129.     <input type="hidden" name="signup_submit" id="signup_submit" value="signup_submit" />
  130.     </td>
  131.     </tr>
  132. </table>
  133. <p>Your Internet Protocol (IP) address is being logged as <?= getenv("REMOTE_ADDR"); ?></p>
  134. </form>
  135. <?
  136. require_once($_SERVER['DOCUMENT_ROOT'] . '/files/includes/footer.php');
  137. }// end of main if/else statement for showing results or not...
  138. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top