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 7926221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:40:38+00:00 2026-06-03T18:40:38+00:00

this is the code i am working on (it is part of this tutorial

  • 0

this is the code i am working on (it is part of this tutorial http://www.homeandlearn.co.uk/php/php4p9.html )

this works fine

`

A BASIC HTML FORM

<?PHP

if (isset($_POST['Submit1'])) {
$username=$_POST['username'];
if($username=="ken"){
    print("you the man");
    }
    else {
        print("you are not supposed to be here");
        }
    }
    else{
        $username="";
        }

?>

</head>
<body>

<FORM NAME ="form1" METHOD ="post" ACTION = "basicForm.php">

username: <INPUT TYPE = "TEXT" VALUE ="<?PHP print $username;?>"NAME="username">

<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">

</FORM>
</body>
</html>`

But this does not

<html>
<head>
<title>A BASIC HTML FORM</title>

<?PHP


if (isset($_POST['Submit1'])) {

$username=$_POST['username'];
$nickname=$_POST['nickname'];
if($username=='ken'and$nickname=='hawk'){
    print("you the man");
    }
    else {
        print("you are not supposed to be here");
        }
    }
    else{
        $username=""and$nickname="";
        }

?>

</head>
<body>

<FORM NAME ="form1" METHOD ="post" ACTION = "testformken.php">

nickname: <input type="text" VALUE ="<?PHP print $nickname;?>" name="nickname" /><br />
username: <input type="text" VALUE ="<?PHP print $username;?>" name="username" />

<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">

</FORM>
</body>
</html>

I get this Notice: Undefined variable: nickname in C:\wamp\www\testformken.php on line 30 Call Stack #TimeMemoryFunctionLocation 10.1800367256{main}( )..\testformken.php:0 ” name=”nickname” />

I have messed with a few things and if i change

nickname: <input type="text" VALUE ="<?PHP print $nickname;?>" name="nickname" /><br />
                      to
nickname: <input type="text" VALUE ="<?PHPprint$nickname;?>" name="nickname" /><br />

I do not get a the undifined variable but it does not print the nickname either
if i change the value to

<?PHP print $username;?> 

enter code here i do not get the undifined variable.

  • 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-03T18:40:42+00:00Added an answer on June 3, 2026 at 6:40 pm

    You’re simply always printing $nickname on your site but you only define it in the if-block (if (isset($_POST['Submit1'])) {) is entered.

    To avoid this, change your printing-part to:

    <?php print isset($nickname) ? $nickname : ''; ?>
    

    Note that I’m using the ternary operator (a shorthand for if-else) here which might be new for you if you’re a beginner.

    To avoid XSS-attacks you also shouldn’t output variables without escaping in real-life usage like Jack suggested (for a tutorial it’s ok to stay simple).

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

Sidebar

Related Questions

I wrote a code using this tutorial http://marakana.com/forums/android/examples/311.html It is working fine except the
Just working through a tutorial on asp.net/mvc for the music store application. Ref: http://www.asp.net/mvc/tutorials/mvc-music-store-part-3
I am following this tutorial http://developers.facebook.com/docs/appsonfacebook/tutorial/ and specifically at this part of code $app_id
This code was working and when we upgraded to php 5.3.10 it stopped working
So basically this code was working fine before. I had some computer issues and
I have been working off of a tutorial of a tower defence game( http://www.guahanweb.com/2009/01/31/tower-defense-in-as3-part-iv/
I have been following this tutorial series for OpenGL : GLUT : http://www.lighthouse3d.com/opengl/glut/ I
Is there a way to run the following script via PHP http://www.magentoadvisor.com/magento-backup/tutorial-magento-backup-scripts-part-2/ I have
http://www.devx.com/wireless/Article/39101/0/page/2 I have followed this tutorial and got it to work and everything. now
Following this tutorial http://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html I have managed to create a simple OSGI bundle and

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.