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

  • Home
  • SEARCH
  • 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 9042541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:31:09+00:00 2026-06-16T10:31:09+00:00

I am trying run a small PHP script. I get an error when I

  • 0

I am trying run a small PHP script. I get an error when I try to run this small PHP line:
<?PHP print $firstname ; ?> within the html code. According to my tutorial guide this line in the value element should ensure that I keep any input text entered into the text fields even after I refresh the browser, but it does not! the following error message occurs:

Notice: Undefined variable: surname in C:\wamp\www\pages\basicForm.php
on line 27 Call Stack #TimeMemoryFunctionLocation 10.0007366504{main}(
)..\basicForm.php:0 ” NAME=”surname”>

Why?

and the code:

<!DOCTYPE html>
<html>
<head>
    <title></title>
        <?PHP
        if (!empty($_POST)) {
            $firstname = $_POST['firstname'];
            $surname = $_POST['surname'];
            print($firstname);
            print($surname);
        }
        else {

        } print( 'welcomes');
    ?>
</head>
<body>
<Form name ="form1" Method ="POST" Action ="basicForm.php">
    <label>


    <INPUT TYPE = 'TEXT' Name ='firstname' VALUE="<?PHP print $firstname ; ?>">
    </label>

    <p>
        <label>
            <INPUT TYPE="TEXT" VALUE="<?PHP print($surname); ?>" NAME="surname">
        </label>

    <p>
        <Input Type = "Submit" Name = "Submit1" Value = "Login">
</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-06-16T10:31:11+00:00Added an answer on June 16, 2026 at 10:31 am

    All you need to assign initial value as below

    $firstname = '';
    $surname = '';
    

    Relying on the default value of an uninitialized variable is
    problematic in the case of including one file into another which uses
    the same variable name. It is also a major security risk with
    register_globals turned on. E_NOTICE level error is issued in case of
    working with uninitialized variables, however not in the case of
    appending elements to the uninitialized array. isset() language
    construct can be used to detect if a variable has been already
    initialized.

    Read more in detail: PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a small javascript script. one of the parameters of
Im trying to run this code : #!/usr/bin/env python The example presented at the
I am quite new to VIM and trying to run a small java code
complete Novice to PHP and HTML so this could be a schoolboy error. I'm
I am trying to create a small script that is to run in the
I'm trying to run python setup.py a small script on a Linode instance where
I'm trying to run the following code $(select#shipping_rates_drop).change(function(){ var selectedText = $(this + option:selected).text();
I am trying to run LibreOffice's examples in a small Maven project. Netbeans does
I was developing a small function when trying to run an enumerator across a
I am trying to write a small Java application that will let me run

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.