If you want more of my pastes visit: https://randompaste.000webhostapp.com/index.html
--------------------------------------------------------------------------------------
You have won:
";
}
$n++;
//print "$n1[user]
";
$user = $n1[user];
$prize = translation2($n1[prize]);
//once it's updated with prizes 101-103 i can set $printcountorsomething to sql fetch of
if ($n1[prize] == 5) { $postcards = $postcards + 1; }
if ($n1[prize] == 12) { $postcards = $postcards + 1; }
if ($n1[prize] == 13) { $prints = $prints + 1; }
if ($n1[prize] == 15) { $prints = $prints + 1; }
if ($n1[prize] == 19) { $prints = $prints + 5; } //Propogate the database with more individual 8.5x11's
//might want to have a function that replaces prize numbers with a resolved 101 prize of 4x6 and resolved 102 prize of 8.5x11 and have one line in prizes for each attached to the claimcode
if ($n1[prize] == 21) { $prints = $prints + 5; }
if ($n1[prize] == 25) { $prints = $prints + 2; }
if ($n1[prize] == 26) { $prints = $prints + 10; }
if ($n1[prize] == 32) { $prints = $prints + 1; }
if ($n1[prize] == 37) { $prints = $prints + 1; }
if ($n1[prize] == 22) { $posters = $posters + 1; }
if ($n1[prize] == 29) { $posters = $posters + 3; }
print "$prize";
print "
";
}
//var_dump($_POST);
//quick little function to parse through the posted prints
$fname = $_POST['FName'];
$lname = $_POST['LName'];
$paint = $_POST['Paint'];
$signed = $_POST['Signed'];
$address1 = $_POST['Address1'];
$address2 = $_POST['Address2'];
$city = $_POST['City'];
$country = $_POST['country'];
$province = $_POST['province'];
$state = $_POST['state'];
$othercountry = $_POST['othercountry'];
$otherstate = $_POST['otherstate'];
$zip = $_POST['Zip'];
if ($country == "Canada") {
$canada = "selected=yes";
if ($province) {
if ($province == "BC") { $bc = "selected=yes"; }
if ($province == "AB") { $ab = "selected=yes"; }
if ($province == "SK") { $sk = "selected=yes"; }
if ($province == "MB") { $mb = "selected=yes"; }
if ($province == "ON") { $on = "selected=yes"; }
if ($province == "QB") { $qb = "selected=yes"; }
if ($province == "NL") { $nl = "selected=yes"; }
if ($province == "NB") { $nb = "selected=yes"; }
if ($province == "NS") { $ns = "selected=yes"; }
if ($province == "PE") { $pe = "selected=yes"; }
if ($province == "YK") { $yk = "selected=yes"; }
if ($province == "NV") { $nv = "selected=yes"; }
if ($province == "NT") { $nt = "selected=yes"; }
}
}
elseif ($country == "US") {
$us = "selected=yes";
if ($state) {
if ($state == "AK") { $ak = "selected=yes"; }
if ($state == "AR") { $ar = "selected=yes"; }
if ($state == "AL") { $al = "selected=yes"; }
if ($state == "AZ") { $az = "selected=yes"; }
if ($state == "CA") { $ca = "selected=yes"; }
if ($state == "CO") { $co = "selected=yes"; }
if ($state == "CT") { $ct = "selected=yes"; }
if ($state == "DE") { $de = "selected=yes"; }
if ($state == "FL") { $fl = "selected=yes"; }
if ($state == "GA") { $ga = "selected=yes"; }
if ($state == "HI") { $hi = "selected=yes"; }
if ($state == "IA") { $ia = "selected=yes"; }
if ($state == "ID") { $id = "selected=yes"; }
if ($state == "IL") { $il = "selected=yes"; }
if ($state == "IN") { $in = "selected=yes"; }
if ($state == "KS") { $ks = "selected=yes"; }
if ($state == "KY") { $ky = "selected=yes"; }
if ($state == "LA") { $la = "selected=yes"; }
if ($state == "MA") { $ma = "selected=yes"; }
if ($state == "MD") { $md = "selected=yes"; }
if ($state == "ME") { $me = "selected=yes"; }
if ($state == "MI") { $mi = "selected=yes"; }
if ($state == "MN") { $mn = "selected=yes"; }
if ($state == "MO") { $mo = "selected=yes"; }
if ($state == "MS") { $ms = "selected=yes"; }
if ($state == "MT") { $mt = "selected=yes"; }
if ($state == "NC") { $nc = "selected=yes"; }
if ($state == "ND") { $nd = "selected=yes"; }
if ($state == "NE") { $ne = "selected=yes"; }
if ($state == "NH") { $nh = "selected=yes"; }
if ($state == "NJ") { $nj = "selected=yes"; }
if ($state == "NM") { $nm = "selected=yes"; }
if ($state == "NV") { $nv = "selected=yes"; }
if ($state == "NY") { $ny = "selected=yes"; }
if ($state == "OH") { $oh = "selected=yes"; }
if ($state == "OK") { $ok = "selected=yes"; }
if ($state == "OR") { $or = "selected=yes"; }
if ($state == "PA") { $pa = "selected=yes"; }
if ($state == "RI") { $ri = "selected=yes"; }
if ($state == "SC") { $sc = "selected=yes"; }
if ($state == "SD") { $sd = "selected=yes"; }
if ($state == "TN") { $tn = "selected=yes"; }
if ($state == "TX") { $tx = "selected=yes"; }
if ($state == "UT") { $ut = "selected=yes"; }
if ($state == "VA") { $va = "selected=yes"; }
if ($state == "VT") { $vt = "selected=yes"; }
if ($state == "WA") { $wa = "selected=yes"; }
if ($state == "WI") { $wi = "selected=yes"; }
if ($state == "WV") { $wv = "selected=yes"; }
if ($state == "WY") { $wy = "selected=yes"; }
if ($state == "AS") { $as = "selected=yes"; }
if ($state == "DC") { $dc = "selected=yes"; }
if ($state == "GU") { $gu = "selected=yes"; }
if ($state == "MP") { $mp = "selected=yes"; }
if ($state == "PR") { $pr = "selected=yes"; }
if ($state == "VI") { $vi = "selected=yes"; }
}
}
elseif ($country == "Other") { $other = "selected=yes"; }
else { $country = "Canada"; $canada = "selected=yes"; $province_not_selected = "selected=yes"; }
if
(isset($_REQUEST['submitted'])) {
// Initialize error array.
$errors = array();
// Check for a proper First name
if (!empty($_REQUEST['FName'])) {
$FName = $_REQUEST['FName'];
$pattern = "/^[a-zA-Z]{2,20}/";
if (preg_match($pattern,$FName)){ $FName = $_REQUEST['FName'];}
else{ $errors[] = 'Your First name can only contain A-Z or a-z and be 2-20 characters long.';}
} else {$errors[] = 'You forgot to enter your First Name.';}
// Check for a proper Last name
if (!empty($_REQUEST['LName'])) {
$LName = $_REQUEST['LName'];
$pattern = "/^[a-zA-Z]{1,30}/";
if (preg_match($pattern,$LName)){ $LName = $_REQUEST['LName'];}
else{ $errors[] = 'Your Last name can only contain A-Z or a-z and be 1-20 characters long.';}
} else {$errors[] = 'You forgot to enter your Last Name.';}
//Address
if (!empty($_REQUEST['Address1'])) {
$Address1 = $_REQUEST['Address1'];
$pattern = "/^[a-zA-Z0-9\_]{1,100}/";
if (preg_match($pattern,$Address1)){ $Address1 =
$_REQUEST['Address1'];}
else{ $errors[] = 'Your Address 1 can only contain _, 1-9, A-Z or a-z 1-100
long.';}
} else {$errors[] = 'You forgot your Address 1.';}
//Address 2
if (!empty($_REQUEST['Address2'])) {
$Address2 = $_REQUEST['Address2'];
$pattern = "/^[a-zA-Z0-9\_]{1,100}/";
if (preg_match($pattern,$Address2)){ $Address2 = $_REQUEST['Address2'];}
else{ $errors[] = 'Your Address 2 can only contain _, 1-9, A-Z or a-z
2-100 long.';}
}
//Signed too
if (!empty($_REQUEST['Signed'])) {
$Signed = $_REQUEST['Signed'];
} else {
$Signed = $FName;
}
function checkPaint($checktype) {
$z = 1;
$errors = array();
while (isset($_REQUEST["{$checktype}{$z}"])) {
print_r($_REQUEST);
print "REQUEST: " . $_REQUEST["{$checktype}{$z}"] . "
";
print "
.
" . $_REQUEST["{$checktype}{$z}"] . "
.
";
$check = $_REQUEST["{$checktype}{$z}"];
$against = "-CHOOSE YOUR PAINT-";
print "
";
var_dump($check);
var_dump($against);
if ($_REQUEST["{$checktype}{$z}"] == "-CHOOSE YOUR PAINT-") { $errors[] = "You forgot your $z $checktype";}
elseif ($_REQUEST["{$checktype}{$z}"] == "-") { $errors[] = "You forgot your $z $checktype";}
$z++;
}
print "Errors: ";
var_dump($errors);
return $errors;
}
$errors = array_merge($errors, checkPaint('Postcards'));
$errors = array_merge($errors, checkPaint('Prints'));
$errors = array_merge($errors, checkPaint('Posters'));
// print "
";
// var_dump($errors);
//CITY
if (!empty($_REQUEST['City'])) {
$City = $_REQUEST['City'];
$pattern = "/^[a-zA-Z0-9\_]{1,100}/";
if (preg_match($pattern,$City)){ $City = $_REQUEST['City'];}
else{ $errors[] = 'Your City can only contain _, 1-9, A-Z or a-z 2-100 long.';}
} else {$errors[] = 'You forgot your City.';}
//STATE
if ($country == "US" && empty($_REQUEST['state'])) {
$errors[] = 'You forgot your State.';
}
//PROVINCE
if ($country == "Canada" && empty($_REQUEST['province'])) {
$errors[] = 'You forgot your Province.';
}
//COUNTRY
if (($country == "Other") && (!empty($_REQUEST['othercountry']))) {
$othercountry = $_REQUEST['othercountry'];
$pattern = "/^[a-zA-Z0-9\_]{2,100}/";
if (preg_match($pattern,$othercountry)){ $othercountry = $_REQUEST['othercountry'];}
else{ $errors[] = 'Your Country can only contain _, 1-9, A-Z or a-z
2-100 long.';}
} elseif ($country == "Other") {$errors[] = 'You forgot your Country.';}
//ZIP/POSTAL
if (!empty($_REQUEST['Zip'])) {
$Zip = $_REQUEST['Zip'];
$pattern = "/^[a-zA-Z0-9\_]{2,100}/";
if (preg_match($pattern,$Zip)){ $Zip = $_REQUEST['Zip'];}
else{ $errors[] = 'Your Zip/Postal can only contain _, 1-9, A-Z or a-z
2-100 long.';}
} else {$errors[] = 'You forgot your Zip/Postal.';}
}
//End of validation
/*
*
* MOOOOOOOOOOSSSSSEEEEEEEE HERE!!!!!!!!!!!!!!!!!
*
*/
if (isset($_REQUEST['submitted'])) {
if (empty($errors)) {
$myfile = fopen("Mailing.txt", "a");
$nwln = "\r\n";
$com = ", ";
fwrite ($myfile, "$user - ");
fwrite ($myfile, $Paint);
fwrite ($myfile, "Signed to - $Signed");
fwrite ($myfile, $nwln);
fwrite ($myfile, $nwln);
fwrite ($myfile, "$FName $LName");
fwrite ($myfile, $nwln);
fwrite ($myfile, $Address1);
fwrite ($myfile, $nwln);
if (!empty($Address2)) {
fwrite ($myfile, $Address2);
fwrite ($myfile, $nwln);
}
fwrite ($myfile, $City);
fwrite ($myfile, $com);
if (!empty($state)) {
fwrite ($myfile, $state);
fwrite ($myfile, $com);
}
if (!empty($province)) {
fwrite ($myfile, $province);
fwrite ($myfile, $com);
}
if (!empty($otherstate)) {
fwrite ($myfile, $otherstate);
fwrite ($myfile, $com);
}
if ($country == "US") { $country = "USA"; }
if ($country == "Other") { $country = $othercountry; }
fwrite ($myfile, $country);
fwrite ($myfile, $nwln);
$Zip = strtoupper($Zip);
fwrite ($myfile, $Zip);
fwrite ($myfile, $nwln);
fwrite ($myfile, $nwln);
fwrite ($myfile, $nwln);
fwrite ($myfile, $nwln);
$link = mysql_connect($host, $login, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$provinceForTheDatabase = $province . $state . $otherstate;
mysql_query("REPLACE INTO addresses
(user, firstname, lastname, addy1, addy2, city, province, country, zip)
VALUES
('$user', '$FName', '$LName', '$Address1', '$Address2', '$City', '$provinceForTheDatabase', '$country', '$zip')") or die(mysql_error());
mysql_close($link);
//for moving prizes from prizes to prizes-claimed
$link = mysql_connect($host, $login, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$prizes_to_move = mysql_query("select * from prizes where claimcode=$claimcode") or die(mysql_error());
$print_number = 1;
$postcards_number = 1;
$posters_number = 1;
while($n1=mysql_fetch_array($prizes_to_move)) {
// print_r($n1);
// print "
Translation:";
// print translation2($n1[prize]);
// print "
.
";
if (translation2($n1[prize]) == "4x6 Print") {
$id = $n1[id];
$prize = $n1[prize];
$print_title = $_POST['Postcards' . $postcards_number];
$sign_to = $_POST['Signed_Postcards_' . $postcards_number];
if (!$sign_to) { $sign_to = $FName; }
$ctime = $n1[ctime];
print "
4x6
INSERT INTO `prizes-claimed`
(`user`, `prize`, `4x6`, `SignTo`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', '$print_title', '$sign_to', $ctime, $claimcode)";
mysql_query("INSERT INTO `prizes-claimed`
(`user`, `prize`, `4x6`, `SignTo`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', '$print_title', '$sign_to', $ctime, $claimcode)") or die(mysql_error());
mysql_query("DELETE FROM `prizes` WHERE `id`=$id") or die(mysql_error());
$postcards_number++;
}
elseif ((translation2($n1[prize]) == "8.5x11 Print") || (translation2($n1[prize]) == "6 Months Print")) {
$id = $n1[id];
$prize = $n1[prize];
$print_title = $_POST['Prints' . $print_number];
$sign_to = $_POST['Signed_Prints_' . $print_number];
if (!$sign_to) { $sign_to = $FName; }
$ctime = $n1[ctime];
/*
print "
8.5x11
INSERT INTO `prizes-claimed`
(`user`, `prize`, `8.5x11`, `SignTo`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', '$print_title', '$sign_to', $ctime, $claimcode)";
*/
mysql_query("INSERT INTO `prizes-claimed`
(`user`, `prize`, `8.5x11`, `SignTo`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', '$print_title', '$sign_to', $ctime, $claimcode)") or die(mysql_error());
mysql_query("DELETE FROM `prizes` WHERE `id`=$id") or die(mysql_error());
$print_number++;
}
elseif (translation2($n1[prize]) == "12x18 Poster") {
$id = $n1[id];
$prize = $n1[prize];
$print_title = $_POST['Posters' . $posters_number];
$sign_to = $_POST['Signed_Posters_' . $posters_number];
if (!$sign_to) { $sign_to = $FName; }
$ctime = $n1[ctime];
mysql_query("INSERT INTO `prizes-claimed`
(`user`, `prize`, `12x18`, `SignTo`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', '$print_title', '$sign_to', $ctime, $claimcode)") or die(mysql_error());
mysql_query("DELETE FROM `prizes` WHERE `id`=$id") or die(mysql_error());
$posters_number++;
}
else {
$id = $n1[id];
$prize = $n1[prize];
$ctime = $n1[ctime];
mysql_query("INSERT INTO `prizes-claimed`
(`user`, `prize`, `ctime`, `claimcode`)
VALUES
('$user', '$prize', $ctime, $claimcode)") or die(mysql_error());
mysql_query("DELETE FROM `prizes` WHERE `id`=$id") or die(mysql_error());
}
print "
";
}
}
}
/*
*
* END FORMATTING!!!!!!!!!!!!!!!!!
*
*/
?>
If the information below is not correct, go back and send moose another whisper.
'; print ("$userFill out the form below to get your prize(s).