} ?>
include 'connect4.inc';
$DISPLAY = $_POST;
if($_GET['sub'] == 'complete'){
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$comp_name = $_POST['comp_name'];
$address = $_POST['mailing_address_1'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$month = $_POST['month'];
$am_id = implode(",",$_POST['am_id']);
$status = "0";
$biz_title = $_POST['title'];
$opt_inla001 = $_POST['opt_inla001'];
$opt_inla002 = $_POST['opt_inla002'];
$opt_inla003 = $_POST['opt_inla003'];
$opt_inla004 = $_POST['opt_inla004'];
$opt_inla005 = $_POST['opt_inla005'];
$opt_inla = $opt_inla001 . ", " . $opt_inla002 . ", " . $opt_inla003 . ", " . $opt_inla004 . ", " . $opt_inla005;
$ylist_id = implode(",",$_POST['ylist']);
$needs = implode(",",$_POST['needs']);
//password generator
function genRandomString() {
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXZY';
$string = '';
for ($p = 0; $p < 3; $p++) {
$string .= $letters[mt_rand(0, strlen($letters))];
}
for ($p = 0; $p < 6; $p++) {
$string .= mt_rand(0, 9);
}
return $string;
} //END genRandomString
$passwordCheck = true;
$pass = '';
//checks to make sure password doesn't already exist
while($passwordCheck){
$pass = genRandomString();
$sql = "SELECT * FROM subscribe where pass = '" . $pass . "'";
$result = $conn->query($sql);
$count = mysqli_num_rows($result);
if($count == 0){
$passwordCheck = false;
}
}
//attempts to insert subscriber into subscribe table
$sql = "INSERT INTO subscribe (biz_title, brand, comp_name, sal, first_name, last_name, address, address_2, city, state, zip, country,".
"mail_to, alt, area_code, phone, area_code_fax, fax, email, month, subscribe, status, am_id, opt_inla, opt_inlc, opt_intle, opt_ineb, pass,".
"edited) VALUES ".
"('$biz_title', '$brand', '$comp_name', '$sal', '$first_name', '$last_name', '$address', '$address_2', '$city' , '$state', '$zip', '$country', ".
"'$mail_to', '$alt_mail', '$area_code', '$phone', '$area_code_fax', '$fax', '$email','$month', ".
"'$subscribe', '$status', '$am_id', '$opt_inla', '$opt_inlc', '$opt_intle', '$opt_ineb', '$pass', NULL)";
if(mysqli_query($conn, $sql)){
echo "";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
//attempts to update ylist on subscriber from above
$sql = "UPDATE subscribe SET ylist_id = '" . $ylist_id . "', needs = '" . $needs . "' WHERE first_name='" . $first_name . "' AND last_name='" . $last_name . "' AND email='" . $email . "'";
if(mysqli_query($conn, $sql)){
echo "";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
//sends password to user
$to = $email;
$subject = ' Re: LADetails Account';
$msg = $first_name . ", you have successfully completed the New Subscription Request Application. \n" .
"Here is your password for LandscapeArchitect.com: \n" .
"Password: " . $pass . "\n".
" \n" .
"We encourage you to browse the Product Information Request page and request \n" .
"any product information you need from our vendors. In order to provide you \n" .
"with timely service, all product information requests are processed weekly. \n" .
" \n" .
"Thank you for visiting LandscapeArchitect.com. \n" .
" \n" .
"The largest landscape oriented database on the web!" ;
mail ($to, $subject, $msg, 'From:' . $email);
$DISPLAY = [];
?>
Congratulations echo $first_name ?>
You have successfully completed the New Subscription Request Application. Once your request has been processed, you will be notified by email of your acceptance status and will be given a password to access/edit your profile and/or download LADetails
} else {
if($_GET['number']){
$number = "&number=" . $_GET['number'];
}
if($_GET['prodNum']){
$prodNum = "&prodNum=" . $_GET['prodNum'];
}
?>
} ?>
if($_GET['sub'] == "complete"){ ?>
$_SESSION['magSub'] = 'yes';
} else { ?>
} ?>