// 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 = "lattner@apple.com,clattner@apple.com,dkipping@qualcomm.com"; $subject = "LLVM Dev Meeting Student, Presenter, and Active Contributor Funding Request"; $body = '
'; $body .= 'Name: ' . $_POST['first'] . ' ' . $_POST['last'] . '
'; $body .= 'School/Organization: ' . $_POST['school'] . '
'; $body .= 'Email: ' . $_POST['email'] . '
'; $body .= 'Location: ' . $_POST['location'] . '
'; if($_POST['level'] == 1) $level = "Undergraduate"; else if($_POST['level'] == 2) $level = "Graduate"; else $level = "Not a student"; $body .= 'Level: ' . $level . '
'; if($_POST['type'] == 1) $type = "Partial"; else $type = "Full"; $body .= "Funding Level: " . $type . '
'; $body .= 'Estimated airfare cost: ' . $_POST['airfare'] . '
'; $body .= 'Estimated loding cost: ' . $_POST['lodging'] . '
'; $body .= 'Estimated other costs: ' . $_POST['other'] . '
'; $body .= 'Reasons for needing funding: ' . $_POST['comments'] . '
'; $body .= ''; $headers = 'From: lattner@apple.com' . "\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'); $sql = "INSERT into students (lastName, firstName, school, email, level, location, airfare, lodging, other, type, comments) VALUES('$_POST[last]', '$_POST[first]', '$_POST[school]', '$_POST[email]', '$_POST[level]', '$_POST[location]','$_POST[airfare]', '$_POST[lodging]', '$_POST[other]', '$_POST[type]', '$_POST[comments]')"; mysql_query($sql) or die(mysql_error()); print 'Your request for funding to attend the LLVM Developers\' Meeting has been submitted. We will contact you once funds have been allocated.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['school'] == "") array_push($errors, "School/Organization must be provided"); if ($_POST['location']=="") array_push($errors, "Location must be provided"); if ($_POST['airfare'] == "") array_push($errors, "Estimate airfare expense must be provided"); else { if ($_POST['airfare'] != strval(intval($_POST['airfare']))) { array_push($errors, "Estimate airfare expense must be an integer"); } } if ($_POST['lodging'] == "") array_push($errors, "Estimate lodging expense must be provided"); else { if ($_POST['lodging'] != strval(intval($_POST['lodging']))) { array_push($errors, "Estimate lodging expense must be an integer"); } } if ($_POST['other'] == "") array_push($errors, "Estimate other expense must be provided"); else { if ($_POST['other'] != strval(intval($_POST['other']))) { array_push($errors, "Estimate other expense must be an integer"); } } if ($_POST['comments'] == "") array_push($errors, "Please provide reasons for needing funding"); if ($_POST['level'] == "") array_push($errors, "Please select type of student"); if ($_POST['type'] == "") array_push($errors, "Please select type of support"); 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 ''; } // Specific to our length drop down list. function inputList($name, $values) { print ''; } function showForm($errors) { if($errors) { print ''; print 'Errors:
'; print'