// Database details. include("connectDB.php"); mysql_connect("127.0.0.1", $user, $password) or die(mysql_error()); mysql_select_db($database); virtual("../header.incl"); function notify() { $to = "llvm-devmtg-admin@nondot.org"; $subject = "LLVM Dev Meeting Registration"; $body = '
'; $body .= 'Name: ' . $_POST['first'] . ' ' . $_POST['last'] . '
'; $body .= 'Organization: ' . $_POST['org'] . '
'; $body .= 'Email: ' . $_POST['email'] . '
'; if($_POST['attendBefore'] == 0) $attendBefore = 'No'; else $attendBefore = 'Yes'; $body .= 'Attended Before: ' . $attendBefore . '
'; if($_POST['friday'] == 0) $friday = 'No'; else $friday = 'Yes'; $body .= 'Attend dinner?: ' . $friday . '
'; if($_POST['meal'] == 0) $meal = 'No'; else $meal = 'Yes'; $body .= 'Vegetarian Meal: ' . $meal . '
'; $body .= "Interests: " . $_POST['comments'] . '
'; $body .= ''; $headers = 'From: tonic@nondot.org' . "\r\n"; $headers .= 'Content-Type: text/html; charset="iso-8859-1"'."\n"; mail($to, $subject, $body, $headers); } function my_escape_string(&$item, $key) { $item = mysql_real_escape_string($item); } function processForm() { array_walk($_POST, 'my_escape_string'); if($_POST['attendBefore'] == 0) $attend = 2; else $attend = 1; if ($_POST['friday'] == 0) $friday = 2; else $friday = 1; if ($_POST['meal'] == 0) $meal = 2; else $meal = 1; $sql = "INSERT into attendees (lastName, firstName, organization, email, location, attendBefore, fridayDinner, mealVeg, comments) VALUES('$_POST[last]', '$_POST[first]', '$_POST[org]', '$_POST[email]', '$_POST[location]','$attend', '$friday', '$meal', '$_POST[comments]')"; mysql_query($sql) or die(mysql_error()); print 'Congratulations! You are now registered for the 2009 LLVM Developers\' Meeting.Please sign up for the LLVM Developers\' Meeting mailing list to receive announcements about the event.
'; notify(); } function validateForm() { $errors = array(); // First name must be set. if ($_POST['first'] == "") array_push($errors, "First name must be provided"); if ($_POST['last'] == "") { array_push($errors, "Last name must be provided"); } if ($_POST['email'] == "") array_push($errors, "Email must be provided"); if ($_POST['org'] == "") array_push($errors, "Organization must be provided"); if ($_POST['location']=="") array_push($errors, "Location name must be provided"); if ($_POST['comments'] == "") array_push($errors, "Please specify interests."); return $errors; } // Print single line text box. function inputText($element_name, $size, $maxLength, $values) { print ''; } // Print text area. function inputTextarea($element_name, $row, $column, $values) { print ''; } // Print radio box. function inputRadiocheck($element_name, $values, $element_value) { print ''; } function showForm($errors) { if($errors) { print ''; print 'Errors:
'; print'Registration is now closed.
'; exit; } ?> //exit; if (array_key_exists('verify', $_POST)) { $formErrors = validateForm($_POST); if(!empty($formErrors)) { showForm($formErrors); } else { processForm(); } } else { showForm(); } ?>