PHP contact form white screen : <p>my php contact form works and sends me an email when people fill it out. what is happinging though is when they click submit, the screen goes white and nothing happens. I want the page to refresh or redirect to another page. How Can I get it to refresh?</p>

<p>here is my PHP:</p>

<pre><code>&lt;?php 

// define variables and set to empty values
$name_error = $email_error = "";
$name = $email = $message = $success = "";

//form is submitted with POST method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
  if (empty($_POST["name"])) {
 $name_error = "Name is required";
  } else {
    $name = test_input($_POST["name"]);
    // check if name only contains letters and whitespace
    if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
      $name_error = "Only letters and white space allowed"; 
    }
  }

  if (empty($_POST["email"])) {
    $email_error = "Email is required";
  } else {
    $email = test_input($_POST["email"]);
    // check if e-mail address is well-formed
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
      $email_error = "Invalid email format"; 
    }
  }

  if (empty($_POST["message"])) {
    $message = "";
  } else {
    $message = test_input($_POST["message"]);
  }

  if ($name_error == '' and $email_error == '' ){
      $message_body = '';
     unset($_POST['submit']);
     foreach ($_POST as $key =&gt; $value){
        $message_body .=  "$key: $value\n";
   }

      $to = 'whitandr@oregonstate.edu';
      $subject = 'Contact Form Submit';
     if (mail($to, $subject, $message_body)){
      $success = "Message sent, thank you!";
      $name = $email = $message = '';
  }
 }
</code></pre>

<p>}</p>

<pre><code>function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
 $data = htmlspecialchars($data);
  return $data;
</code></pre>

<p>}</p>
