I'm getting a notice in 1 of my textboxes for some reason
<p>Why do I get the following text in the referer textbox:</p>

<blockquote>
  <p>Notice: Undefined index: referer in
  /var/www/register.php on line 86</p>
</blockquote>

<p>when the following script loads?</p>

<pre><code>&lt;?php
    error_reporting( E_ALL | E_STRICT );
    ini_set('display_errors', 1);
?&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;&lt;/title&gt;
        &lt;link rel="icon" type="image/png" href="favicon.ico"&gt;

        &lt;?php
            $err = array();

            if( $_SERVER['REQUEST_METHOD']=='POST' ) {

                if( empty( $_POST['display_name'] ) ) $err[] = "display name field is required";
                if( empty( $_POST['email'] ) ) $err[] = "email field is required";
                if( empty( $_POST['password'] ) ) $err[] = "password field is required";

                if( !$err ) {
                    try {
                        $DBH = new PDO( "mysql:host=localhost;dbname=database1", "user", "pass" );
                        $DBH -&gt; setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

                        $STH = $DBH -&gt; prepare( "insert into database1.table1 (display_name, email, password) values ( :display_name, :email, :password )" );

                        $STH -&gt; bindParam( ':display_name', $_POST['display_name'], PDO::PARAM_STR, 100 );
                        $STH -&gt; bindParam( ':email', $_POST['email'], PDO::PARAM_STR, 100 );
                        $STH -&gt; bindParam( ':password', $_POST['password'], PDO::PARAM_STR, 100 );

                        $STH -&gt; execute();

                        if( !empty( $_POST['referer'] ) ) {
                            $STH = $DBH -&gt; prepare( "insert into database1.table2 ( username, status, users_id ) values ( :username, :status, :users_id )" );

                            $strStatus = 1;

                            $STH -&gt; bindParam( ':username', $_POST['display_name'], PDO::PARAM_STR, 100 );
                            $STH -&gt; bindParam( ':status', $strStatus, PDO::PARAM_INT, 1 );
                            $STH -&gt; bindParam( ':users_id', $_POST['referer'], PDO::PARAM_INT, 1 );

                            $STH -&gt; execute();
                        }

                        $DBH = null;

                        header( "Location: ".$_SERVER['PHP_SELF'] );
                        exit;
                    } catch( PDOException $e ) {
                        error_log( $e -&gt; getMessage() );

                        switch( $e -&gt; getCode()) {
                            case 23000:
                                echo "Sorry, the referral ID you have entered does not exist.  However, your account has been created so you can add your referral details in later.";
                                break;
                            default:
                                echo $e -&gt; getMessage();      
                        }
                    }


                } else {
                    foreach( $_POST as $key =&gt; $val ) {
                        $form[$key] = htmlspecialchars($val);
                    }
                }
            } else {
                $form['display_name'] = $form['email'] = $form['password'] = '';
            }
        ?&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;?php
            if ( isset( $err ) ) {
                foreach( $err as $line ) {
                    echo "&lt;div style=\"error\"&gt;".$line."&lt;/div&gt;";
                }
            }
        ?&gt;

        &lt;h1&gt;register&lt;/h1&gt;

        &lt;form method="post"&gt;
            referers id:&lt;br /&gt;
            &lt;input type="text" name="referer" value="&lt;?php echo $form['referer']; ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;

            name:&lt;br /&gt;
            &lt;input type="text" name="display_name" value="&lt;?php echo $form['display_name']; ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;

            email:&lt;br /&gt;
            &lt;input type="text" name="email" value="&lt;?php echo $form['email']; ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;

            password:&lt;br /&gt;
            &lt;input type="text" name="password" value="&lt;?php echo $form['password']; ?&gt;" /&gt;&lt;br /&gt;&lt;br /&gt;

            &lt;input type="submit" value="register" /&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
