Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4107040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:27:12+00:00 2026-05-20T21:27:12+00:00

Why do I get the following text in the referer textbox: Notice: Undefined index:

  • 0

Why do I get the following text in the referer textbox:

Notice: Undefined index: referer in
/var/www/register.php on line 86

when the following script loads?

<?php
    error_reporting( E_ALL | E_STRICT );
    ini_set('display_errors', 1);
?>

<html>
    <head>
        <title></title>
        <link rel="icon" type="image/png" href="favicon.ico">

        <?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 -> setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

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

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

                        $STH -> execute();

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

                            $strStatus = 1;

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

                            $STH -> execute();
                        }

                        $DBH = null;

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

                        switch( $e -> 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 -> getMessage();      
                        }
                    }


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

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

        <h1>register</h1>

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

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

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

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

            <input type="submit" value="register" />
        </form>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:27:13+00:00Added an answer on May 20, 2026 at 9:27 pm

    When you are first displaying your form, you are executing this portion of code (line 68) :

    $form['display_name'] = $form['email'] = $form['password'] = '';
    

    This initializes three items of your $form array, which is why you don’t get notices for those when you try to echo them on lines 89, 92, and 95.

    But the referer item of $form is not initialized.

    So, line 86, when you try to echo it :

    <input type="text" name="referer" value="<?php echo $form['referer']; ?>" /><br /><br />
    

    You get a notice.

    Two possible solutions :

    • Do not try to echo a variable (or item of an array) that doesn’t exist.
      • The isset() construct can help, to test for that.
    • Or initialize $form['referer'] before trying to use it.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following text file: This is the first line of
I have the following text below, what is the easiest way to parse through
When trying to use i18n in rails I get the following undesired output. The
I have a text file in which each line is an entry. each line
There's a thrird party app that needs to get information via custom http headers,
I am trying to login to this website https://www.virginmobile.com.au programatically (on the right there
I have servlet that does the following: public class LoginServlet extends HttpServlet { protected
Through rspec (I'm using rspec-1.3.0, rspec-rails-1.3.2 gems) generator ( ruby script/generate rspec_model suggestion section_id:integer
I have the following Hello World code to try out TeX rendering with matplotlib
New to R, and am trying to install the text mining package (tm). However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.