Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('../include/conn.php');
- if (!$_POST or $_POST['name'] == '') { print "Error."; exit; }
- $_POST['arrival'] = date('Y-m-d', strtotime($_POST['arrival']));
- $_POST['departure'] = date('Y-m-d', strtotime($_POST['departure']));
- $_POST['ducky'] = $_POST['ducky'] ? 'Yes' : 'No';
- $_POST['golf'] = $_POST['golf'] ? 'Yes' : 'No';
- if ($_POST['ducky'] == 'No') $_POST['duckyyes'] = '';
- if ($_POST['golf'] == 'No') $_POST['golf'] = '';
- if ($_POST['bellefonte'] == 'No') $_POST['bellefonte'] = '';
- $fields = array(
- 'name' => 'Name',
- 'family' => 'Family',
- 'title' => 'Title',
- 'dealership' => 'Dealership',
- 'address' => 'Address',
- 'city' => 'City/State',
- 'zip' => 'Zip',
- 'email' => 'Email',
- 'telephone' => 'Phone',
- 'arrival' => 'Arrival Date',
- 'departure' => 'Departure Date',
- 'golf' => 'Golf Attending',
- 'golfyes' => ' Golf add. people attending',
- 'ducky' => 'Ducky Attending',
- 'duckyyes' => ' Ducky add. people attending',
- 'bellefonte' => 'Bellefonte',
- 'bellefonteyes' => ' Bellefonte add. people attending',
- );
- $sql = 'INSERT INTO cdupa (' . implode(", ", array_keys($fields)) . ') VALUES (';
- $registration = '';
- foreach ($fields as $f => $v)
- {
- $sql .= "'".mysql_real_escape_string($_POST[$f])."',";
- $registration .= sprintf('%s: ', ucwords($v)) . stripslashes($_POST[$f]) . "\n";
- }
- $sql = trim($sql, ',') . ")";
- // Insert new record
- mysql_query($sql) or die(mysql_error());
- $csv = implode(',',$fields) . "\n";
- $csv_fields = array('id', 'created_at') + array_keys($fields);
- $rs = mysql_query("SELECT ".implode(', ', $csv_fields)." FROM cdupa ORDER BY id") or die(mysql_error());
- while ($row = mysql_fetch_row($rs))
- {
- $csv_row = '';
- foreach ($row as $col)
- {
- $csv_row .= '"'.str_replace('"','', $col).'",';
- }
- $csv .= trim($csv_row, ',') . "\n";
- }
- //define the receiver of the email
- $to = 'mgates@clevelandbrothers.com, Kathy_Williams@Whayne.com';
- //$to = 'curt@webpagefx.com';
- //define the subject of the email
- $subject = 'CDUPA Conference Registration';
- //create a boundary string. It must be unique
- //so we use the MD5 algorithm to generate a random hash
- $random_hash = md5(date('r', time()));
- //define the headers we want passed. Note that they are separated with \r\n
- $headers = "From: webmaster@eclevelandbrothers.com";
- //add boundary string and mime type specification
- $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
- //read the atachment file contents into a string,
- //encode it with MIME base64,
- //and split it into smaller chunks
- $attachment = chunk_split(base64_encode($csv));
- //define the body of the message.
- ob_start(); //Turn on output buffering
- ?>
- --PHP-mixed-<?php echo $random_hash; ?>
- Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
- --PHP-alt-<?php echo $random_hash; ?>
- Content-Type: text/plain; charset="iso-8859-1"
- Content-Transfer-Encoding: 7bit
- Conference Registration
- =======================
- The following person has registered for the 2011 CDUPA Conference:
- <?php echo $registration ?>
- --PHP-alt-<?php echo $random_hash; ?>
- Content-Type: text/html; charset="iso-8859-1"
- Content-Transfer-Encoding: 7bit
- <h2>Conference Registration</h2>
- <p>The following person has registered for the 2011 CDUPA Conference:</p>
- <p>
- <?php echo nl2br($registration); ?>
- </p>
- --PHP-alt-<?php echo $random_hash; ?>--
- --PHP-mixed-<?php echo $random_hash; ?>
- Content-Type: application/csv; name="cdupa_registrations.csv"
- Content-Transfer-Encoding: base64
- Content-Disposition: attachment
- <?php echo $attachment; ?>
- --PHP-mixed-<?php echo $random_hash; ?>--
- <?php
- //copy current buffer contents into $message variable and delete current output buffer
- $message = ob_get_clean();
- //send the email
- $mail_sent = @mail( $to, $subject, $message, $headers );
- header('Location: thankyou.html');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement