Socket){ // go to error if no database connection header("Location: secure/errors/connectionError.php"); }// end if $errors = ""; $type = $_POST['type']; $username = $_POST['username']; $account = $_POST['account']; $zip = $_POST['zip']; $ticket = $_POST['ticket']; $email = $_POST['email']; if (!empty($type) && !empty($username) && !empty($account) && !empty($zip) && !empty($ticket) && !empty($email)){ if (is_numeric($username)) $errors.="User Name must include at least 1 non-numeric character
"; if (strlen($account) > 4) $errors.="Account numbers are only 4 Digits.
"; if (!is_numeric($account)) $errors.="Account Number must be a number.
"; //if (!is_numeric($ticket)) // $errors.="Previous Ticket Number must be a number.
"; if (!is_numeric($zip)) $errors.="Postal Zip Code must be a number.
"; if ($type == "F"){ $allOK = checkDuplicates($dbsSession, "frpUsers", $username, $account); if ($allOK) $allOK = frequentZipTicket($dbdSession, $d3sep, $account, $ticket, $zip); if ($allOK){ $password = insert($dbsSession, "frpUsers", $account, $username, $email); sendEmail($email, $username, $password); $errors.="Your Account has been setup. Your password has been emailed.
"; }// end if }// end if if ($type == "S"){ $allOK = checkDuplicates($dbsSession, "recyclingUsers", $username, $account); if ($allOK) $allOK = scrapZipTicket($dbdSession, $d3sep, $account, $ticket, $zip); if ($allOK){ $password = insert($dbsSession, "recyclingUsers", $account, $username, $email); sendEmail($email, $username, $password); $errors.="Your Account has been setup. Your password has been emailed.
"; }// end if }// if }// end if function checkDuplicates ($dbsSession, $table, $username, $account){ global $errors; $statement = "SELECT * FROM $table WHERE userName = '".$username."'"; $results = mysql_query($statement); $nameCheck = mysql_num_rows($results); if ($nameCheck > 0){ unset($username); unset($account); $errors.="An Account Already exists with this Username.
"; return false; }// end if else { $statement = "SELECT * FROM $table WHERE account = '$account'"; $results = mysql_query($statement); $accountCheck = mysql_num_rows($results); if ($accountCheck > 0){ $errors.="This Account Number is already setup.
"; unset($username); unset($account); unset($zip); unset($ticket); unset($email); return false; }// end if }// end else return true; }// end function function frequentZipTicket ($dbdSession, $d3sep, $account, $ticket, $zip){ global $errors; $command = "LIST fsi:[//pickserver]metro,frequent, '".$account."' by-exp ticket = ".$ticket." zip.short sep ticket col-hdr-supp id-supp ni-supp"; $result = $dbdSession->execute($command); $result = explode("^", $result); $zipCheck = trim($result[0]); $ticketCheck = trim($result[1], " ".$d3sep); if ($ticketCheck != $ticket || $zipCheck != $zip){ if ($ticketCheck != $ticket) $errors.="The Ticket Number Entered Does Not Match Our Records.
"; if ($zipCheck != $zip) $errors.="The Zip Code Entered Does Not Match Our Records.
"; return false; }// end if else return true; }// end function function scrapZipTicket ($dbdSession, $d3sep, $account, $ticket, $zip){ global $errors; $command = "LIST fsi:[//pickserver]metro,tp, '".$ticket."' with vend = '".$account."' ps.zip.short sep ticket col-hdr-supp id-supp ni-supp"; $result = $dbdSession->execute($command); $result = explode("^", $result); $zipCheck = trim($result[0]); $ticketCheck = trim($result[1], " ".$d3sep); if ($ticketCheck != $ticket || $zipCheck != $zip){ if ($ticketCheck != $ticket) $errors.="The Ticket Number Entered Does Not Match Our Records.
"; if ($zipCheck != $zip) $errors.="The Zip Code Entered Does Not Match Our Records.
"; return false; }// end if else return true; }// end function function insert ($dbsSession, $table, $account, $username, $email){ $password = makePassword(); $md5Pass = md5($password); $now = date('Y-m-d'); $statement = "INSERT INTO $table(account, userName, password, email, active, activationDate) VALUES ('".$account."','".$username."', '".$md5Pass."', '".$email."', '1', '".$now."' )"; mysql_query($statement); return $password; }// end function function makePassword (){ $seed = "abcdefghijkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7){ $num = rand() % 33; $tmp = substr($seed, $num, 1); $pass = $pass.$tmp; $i++; }// end while return trim($pass); }// end function function sendEmail($email, $username, $password){ $subject = "Your metro-grp.com Login"; $message = "Dear $username: Thank you for Setting up your metro-grp.com account. Your account is now active and can be viewed by logging in with the following information. Username: $username Temporary Password: $password Please Change your password upon logging in. Go to 'Account Settings' and enter the password above into the 'Current Password' field. Then enter a new password into the 'New Password' field and re-type that password again into the 'Confirm Password' field. Press 'Submit'. If you have any trouble logging in, please email techsupport@metro-grp.com with your Username, Account Number and a description of your problem. Thank You. Metro Group Inc. --- This message was generated automatically, do not reply. --- "; mail($email, $subject, $message, "From: Metro Group Inc. \n"); // header("Location: http://www.metro-grp.com"); }// end function ?> Metro Group Inc. | Home

Online Account Setup
  Please fill out the following information. A temporary password will be email to the address provided. Each Account may only have one username.The submit button will enable when all data is valid. ALL FIELDS ARE REQUIRED.
Account Type:
User Name:
(5 to 15 characters at least 1 non-numeric)
Account Number:4 Digits
Frequent Recycler - Located on Frequent Recycler Card
Scrap Vendor - Located on any Pickup Ticket left of company name
Email Address:
Postal Zip Code:
Previous Ticket Number:
Frequent Recycler - Scale Purchase Receipt Ticket Number
Scrap Vendor - Pickup Ticket Number from the past 30 days

© Copyright 2005, Metro Group Inc. 401 West 900 South Salt Lake City, Utah 84101