How do I clear all form fields after submit?

I need to reset or clear all fields in a form, after the form has been submitted. Any suggestions for an easy way to do that?

Here is the code:


<?php
//----------------------------------
// Load the settings and language file
//----------------------------------
include( 'settings.php' );
include( 'language.php' );

// If the settings couldn't load, stop the script
if( !$configLoaded )
{
    exit;
}

//----------------------------------
// Get the form
//----------------------------------
$form = file_get_contents( $formFile );

//----------------------------------
// Clean out user submitted information
//----------------------------------
foreach( $_POST as $key=>$value )
{
    $_POST[$key] = htmlentities( stripslashes( $value ) );
}
extract( $_POST );

if( $submitSendEmail )
{
    if( !$yourName )
    {
        $error['yourName'] = $txt['forgot']['yourName'];
    }
    if( !$friendName )
    {
        $error['friendName'] = $txt['forgot']['friendName'];
    }
    if( !$friendEmail )
    {
        $error['friendEmail'] = $txt['forgot']['friendEmail'];
    }
    elseif( !preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", $friendEmail ) )
    {
        $error['friendEmail'] = $txt['invalid']['friendEmail'];
    }
    if( !$yourEmail )
    {
        $error['yourEmail'] = $txt['forgot']['yourEmail'];
    }
    elseif( !preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i", $yourEmail ) )
    {
        $error['yourEmail'] = $txt['invalid']['yourEmail'];
    }
    
    if( !$error )
    {
        if( checkLogs() )
        {
            include( 'message.php' );
            $headers  = 'MIME-Version: 1.0' . "\\r\
";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";
            $headers .= 'From: ' . $yourName . '<' . $yourEmail . '>' . "\\r\
";
            
            $txt['email']['subject'] = str_replace( '{yourEmail}', $yourEmail, $txt['email']['subject'] );
            $txt['email']['subject'] = str_replace( '{yourName}', $yourName, $txt['email']['subject'] );
            if( !@mail( $friendEmail, $txt['email']['subject'], $message, $headers ) )
            {
                $error['other'] = $txt['errors']['failedSendingMailToFriend'];
            }
            
            @mail( $notificationEmail, $txt['adminEmail']['subject'], "
            $yourName ($yourEmail) has used the form and sent $friendName($friendEmail) an email!\

            Here are some more details:\

            User's Name: $yourName\

            User's Email: $yourEmail\

            Friend's Name: $friendName\

            Friend's Email: $friendEmail\

            Message:\

            $shortMessage",'From: Send-To-Friend-Script
            IP Of the User: ' . $_SERVER['REMOTE_ADDR'] );
            logTime();
        }
        else
        {
            $error['other'] .= $txt['errors']['pleaseWait'];
        }
    }
}

if( $error )
{
    $error['errors'] = '<div class="error"> ' . $txt['errors']['basicError'] . $error['other'] . '</div>';
}
elseif( $submitSendEmail )
{
    $messages['done'] = str_replace( '{friendName}', $friendName, $txt['done']['thankYou'] );
}
include( 'form.php' );
echo $form;

function logTime()
{
    global $logFile;
        
    $handle = @fopen( $logFile, 'a+' );
    @fwrite( $handle, $_SERVER['REMOTE_ADDR'] . "|" . time() . "\
" );
    @fclose( $handle );
}
function readLog()
{
    global $logFile;
    $log = @file( $logFile );
    if( !$log )
    {
        return false;
    }
    foreach( $log as $lineNum=>$line )
    {
        $line = explode( '|', $line );
        $logArray[$line[0]] = $line[1];
    }
    return $logArray;
}
function checkLogs()
{
    global $timeToWait;
    
    $logArray = readLog();
    $userIP = $_SERVER['REMOTE_ADDR'];
    
    $lastUsed = $logArray[$userIP];
    
    if( !$lastUsed )
    {
        return true;
    }
    elseif( time() - $lastUsed < $timeToWait )
    {
        return false;
    }
    else
    {
        return true;
    }
}
?>

The form looks like this:


<?php
$form = <<<EOF
    <form action="{$_SERVER['PHP_SELF']}" id="form1" name="form1" method="post">
    
    {$messages['done']}
    {$error['errors']}
    
    
    {$error['yourName']}
    <label for="namn">Ditt namn: </label> <input type="text" name="yourName" id="dnamn" value="{$yourName}" />
    <br />
    
    {$error['yourEmail']}
    <label for="depost">Din e-post: </label> <input type="text" name="yourEmail" id="depost" value="{$yourEmail}" />
    <br />
    
    {$error['friendName']}
    <label for="fnamn">Din v&auml;ns namn: </label> <input type="text" name="friendName" id="vnamn" value="{$friendName}" />
    <br />
    
    {$error['friendEmail']}
    <label for="vepost">Din v&auml;ns e-post: </label> <input type="text" name="friendEmail" id="vepost" value="{$friendEmail}" />
    <br />
    
    <label for="text">Meddelande:</label><br />
    <textarea rows="20" cols="40" name="shortMessage">{$shortMessage}</textarea>
    <br />
    
    
    <input type="submit" name="submitSendEmail" id="submitbutton" value="S&auml;nd!" />

    </form>
    
EOF;
//Do not erase the 'EOF;'
?>

You will need to clear the values that are being put into value=“{$yourName}”, etc… Just unset those variables after the form has been processed.