Login | Register | FAQ
Anonymous

Notice: Undefined index: fname in C:\xampp\htdocs\handler.ph

+ Post a reply

Page 1 of 1


Notice: Undefined index: fname in C:\xampp\htdocs\handler.ph

by waw » Wed Aug 29, 2012 9:08 am

Can anyone help me. I'm just starting to learn php,Im getting this error when i tried to use $_GET or $_POST in my form.(Notice: Undefined index: fname in C:\xampp\htdocs\handler.php on line 5).Please check below for my php and html code for reference. thank you.
//php code
Welcome <?php echo $_GET["fname"]; ?>!<br />
You are <?php echo $_GET["age"]; ?> years old!

//html code
<form action="handler.php" method="post">
Name: <input type="text" name="fname"/><br/>
Age: <input type="text" name = "age"/><br/>
<input type="submit"/>
</form>
User avatar

waw

  • Posts: 1
  • Joined: Wed Aug 29, 2012 9:00 am

Re: Notice: Undefined index: fname in C:\xampp\htdocs\handle

by XainPro » Thu Aug 30, 2012 10:54 am

well its not wrror its just
Notice:
it means before using the variable you need to declare it just like you did in C language
$name= "";

if($name == "")
{

}

etc

just like i defined the name variable before using it in if class.
User avatar

XainPro

  • Posts: 3311
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1