Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- /*xxxxxxxx prepare variables xxxxxxxx*/
- $ticket_no = ""; //auto-increments
- $fname = filter_input(INPUT_POST, 'fname', FILTER_DEFAULT);
- $lname = filter_input(INPUT_POST, 'lname', FILTER_DEFAULT);
- $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
- $phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_NUMBER_INT);
- /*xxxxxxx hidden form inputs xxxxxxxx*/
- $filePath = $_POST ['filePath'];
- $raffle_id = $_POST['raffle_id'];
- $prize_id = $_POST['prize_id'];
- $ticketPrice = $_POST['ticketPrice'];
- $paymentMethod = $_POST['paymentMethod'];
- /*xxxxxxx connect to dbase xxxxxxxx*/
- $server = "localhost";
- $user = "me";
- $password = "pw";
- $database = "db";
- $link = mysqli_connect($server, $user, $password, $database);
- mysqli_select_db($link, $database);
- /*xxxxxxx check for discount xxxxxxx*/
- $SQL = "SELECT * FROM discount_test
- WHERE fname = $fname && lname = $lname && email = $email";
- if(fname == $fname && lname == $lname && email == $email)
- {
- $discountYN = "yes";
- $ticketPrice = $ticketPrice - ($ticketPrice * .10);
- $discountTxt = "You received a 10% discount on your ticket purchase. Your ticket price was $$ticketPrice.
- Best of luck to you!
- Rockin' Randy";
- }
- else
- {
- $discountYN = "no";
- $discountTxt = "Best of luck to you!
- Rockin' Randy";
- }
- /*xxxxxxxxc insert data xxxxxxxxx*/
- $SQL="INSERT INTO entrants_test SET
- ticket_no = '$ticket_no',
- fname = '$fname',
- lname = '$lname',i
- email = '$email',
- phone = '$phone',
- raffle_id = '$raffle_id',
- paymentMethod = '$paymentMethod',
- purchaseDate = CURRENT_DATE(),
- discountYN = '$discountYN'
- ";
- mysqli_query($link, $SQL);
- /*xxxxxxxxxc test insertion xxxxxxxxxxc*/
- if(mysqli_errno($link))
- {
- // notify admin of error
- $to = "me@mySite.com";
- $subject = "Error number: " . mysqli_errno($link);
- $txt = mysqli_error($link);
- $headers = "From: ErrorNotification@mySite.com";
- mail($to,$subject,$txt,$headers);
- // display error mssg on page
- $errorTxt = "<p>We're sorry, your entry was not accepted. Error number "
- . mysqli_errno($link) . ". " . "<br />"
- . mysqli_error($link)
- . "<p>The administrator has been sent an email notification of this error, and it will be corrected as soon as possible.</p>";
- }
- else
- {
- /*xxxxxxxx get ticket number xxxxxxx*/
- $SQL = "SELECT COUNT(*)
- FROM entrants_test";
- $result = mysqli_query($link, $SQL);
- $rowcount = mysqli_fetch_array($result);
- $rowcount = $rowcount[0];
- $ticket_no = $rowcount;
- /* xxxxxxxxxxx Send e-ticket xxxxxxxxx */
- $to = $email;
- $subject = "TICKET NUMBER: $ticket_no.";
- $txt = "Thank you, $fname, for supporting us by entering $brand $artist $model Raffle No. $raffleNo. Save this email as your your e-Ticket (No. $ticket_no) and proof of purchase.
- $discountTxt ";
- $headers = "From: TicketPurchase@mySite.com";
- mail($to,$subject,$txt,$headers);
- /*xxxxxxx if 1000, select winner xxxxxxx*/
- if($ticket_no == 1000)
- {
- include("selectWinner.php");
- }
- }
- mysqli_close($link);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement