session_start(); require_once($_SERVER['DOCUMENT_ROOT'] . "includes/functions/form_validation.php"); require_once($_SERVER['DOCUMENT_ROOT'] . "includes/layout/header.php"); $code = isset($_GET['code']) ? $_GET['code'] : (isset($_POST['name']) ? "send" : "write_message"); switch($code) { case "write_message": $problem_page = $_SERVER['HTTP_REFERER']; list($name, $email, $message) = array_fill(0,3,""); list($name_error, $email_error, $message_error) = array_fill(0,3,false); ?>
If you have encountered a problem with the ICOMM web site, please use the form below to contact our web master. All of the fields are necessary. We apologize for any inconvience that we may have caused for you.
print_form(); break; case "error": list($problem_page, $name, $email, $message) = array_values($_SESSION['form_data']); list($name_error, $email_error, $message_error) = array_values($_SESSION['form_errors']);?>There were one or more problems in the information you entered on the previous screen. Your entries have been placed in the fields below accompanied by error messages to help you solve any problems that cropped up. When you have solved the problems below, click the button to send your message.
print_form(); break; case "send": $errors = array(); foreach($_POST as $field => $value) { if($field == "problem_page") continue; $errors[$field] = strlen($value)<=0 ? "missing" : false; } foreach($errors as $error) { if($error !== false) { $_SESSION['form_data'] = $_POST; $_SESSION['form_errors'] = $errors; header("Location: contact_webmaster.php?code=error"); exit; } } list($problem_page, $name, $email, $message) = array_values($_POST); $message = "$name has sent you the following message from the ICOMM web site:\n\n$message\n\nProblem page: $problem_page"; $delivery_success = mail("ddkees@uiuc.edu", "ICOMM Web Site Error", $message, "From: $email"); if(!$delivery_success) // if the delivery of the message was unsuccessful, we'll try to remove the "From:" header in the email and see // if we can send it that way. this could be necessary if someone incorrectly enters their email address mail("ddkees@uiuc.edu", "ICOMM Web Site Error", $message); ?>Your message has been sent to out web master. If necessary, he will contact you at the email address you entered if he needs your assistance in solving this problem. Thank you for your interest in the Internation Conference of Micromanufacturion and for informing us of this problem.
break; } function print_form() { global $problem_page, $name, $name_error, $email, $email_error, $message, $message_error; ?> } ?> require_once($_SERVER['DOCUMENT_ROOT'] . "includes/layout/footer.php"); ?>