Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Prakhar Patwa](https://uploads.teamtreehouse.com/production/profile-photos/2790072/micro_1560580_702136186477591_1988909480_n.jpg)
Prakhar Patwa
11,260 PointsUndefined variable
please have a look at my code, i have used bootstrap. My form is slightly different as well as the process. On the top of the page i have declared $results variable. But when i am trying to display it, It's showing me undefined variable
![Prakhar Patwa](https://uploads.teamtreehouse.com/production/profile-photos/2790072/micro_1560580_702136186477591_1988909480_n.jpg)
Prakhar Patwa
11,260 Points@Ron baasland just before where the form tag , Sorry its a big chunk of html
![Ron Baasland](https://secure.gravatar.com/avatar/8c321b42136d62d2e367dc7631744512?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ron Baasland
41,606 PointsIt seems as though you haven't filled out your <form> declaration. It is not set to method="post" so the $_POST["submit"] is not available so the variable $results is not being set.
![Prakhar Patwa](https://uploads.teamtreehouse.com/production/profile-photos/2790072/micro_1560580_702136186477591_1988909480_n.jpg)
Prakhar Patwa
11,260 Points@Ron i am not getting it, what are you trying to say?
![Ron Baasland](https://secure.gravatar.com/avatar/8c321b42136d62d2e367dc7631744512?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ron Baasland
41,606 PointsNevermind about my last comment, I was looking at something else.
Andrew McCormick
17,730 Pointsjust a mod note that I cleaned up the question to be a little clearer
3 Answers
![Ron Baasland](https://secure.gravatar.com/avatar/8c321b42136d62d2e367dc7631744512?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ron Baasland
41,606 PointsSince your submit button doesn't have a value declared $_POST["submit"] does not have a value so if($_POST["submit"]) is false so the $results variable never gets set. You can either add a value to your submit button, or set if($_POST["submit"] == "")
Andrew McCormick
17,730 PointsJust adding to what Ron said, if you are going to echo the $results variable without checking to see if it's set first, then you need make sure it's set. Therefore when you declare it up top, rather than just using
<?php
if($_POST["submit"]){
$results = "form has submitted";
}
?>
use
<?php
if($_POST["submit"]){
$results = "form has submitted";
}else {
$results = "no current submissions "; //or something like that
}
?>
![Prakhar Patwa](https://uploads.teamtreehouse.com/production/profile-photos/2790072/micro_1560580_702136186477591_1988909480_n.jpg)
Prakhar Patwa
11,260 Pointsyess after breaking my head.....i got that. thanks to both of you.
![Prakhar Patwa](https://uploads.teamtreehouse.com/production/profile-photos/2790072/micro_1560580_702136186477591_1988909480_n.jpg)
Prakhar Patwa
11,260 PointsI have 1 more question
i haven't bought domain name yet, so if i put the email which i have created on ecowebhosting.com in the mail boxes option, That is why it is not sending?
But i recieve message when i put my gmail id in the code
Ron Baasland
41,606 PointsRon Baasland
41,606 PointsI saw your variable at the top of the page, but I couldn't find where you were trying to display it.