title: Can't write HTML and PHP code in the same page
body: <p>I am trying to write a simple code for php form. I wrote the php code in the same page as html. Name of the php page is signup.php
  But I am getting error like this:</p>
  
  <blockquote>
    <p>Notice: Undefined index: nm in
    C:\xampp\htdocs\mini_project\signup2.php on line 5</p>
    
    <p>Notice: Undefined index: email in
    C:\xampp\htdocs\mini_project\signup2.php on line 6</p>
  </blockquote>
  
  <p>If I separate the php and html code in two different pages there is no problem with my code.</p>
  
  <p>Why can't I write php and html in the same page? What I am doing wrong?</p>
  
  <p>I am using php 7. </p>
  
  <pre><code>  &lt;?php
  
     include 'connect.php'
  
  $nm = $_POST['nm'];
  $email = $_POST['email'];
  $password = $_POST['password'];
  $cpassword = $_POST['cpassword'];
  $type = $_POST['type'];
  $remember = $_POST['remember'];
  $signup = $_POST['signup'];
  
  if (isset($signup))
  {
  
    $query = "INSERT INTO user_details (nm,email,pass,user_type) VALUES ('$nm','$email','$password','$type')";
   $result = mysqli_query($conn,$query);
   }
  ?&gt;
  
  
      &lt;!DOCTYPE html&gt;
       &lt;html&gt;
        &lt;head&gt;
     &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
  
   &lt;link href="css/bootstrap.min.css" rel="stylesheet" media="screen"&gt;
     &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
   &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  
       &lt;body&gt;
       &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-4 col-md-offset-4"&gt;
              &lt;div class="login-panel panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;
                      &lt;h3 class="panel-title"&gt;Please Sign In&lt;/h3&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;form role="form" method="post" action="signup.php"&gt;
                          &lt;fieldset&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Please Enter Name" name="nm" id="nm" type="text" autofocus&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Please Enter E-mail" name="email" id="email" type="email"&gt;
                              &lt;/div &gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Please Enter Password" name="password" id="password" type="password" value=""&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Please Confirm Password" name="cpassword" id="cpassword" type="password" value=""&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;select class="form-control" align="center" name="type"&gt;
                                      &lt;option value="0"&gt;Please Select User Type&lt;/option&gt;
                                      &lt;option value="1"&gt;I want to Hire&lt;/option&gt;
                                      &lt;option value="Second Year"&gt;I want to Work&lt;/option&gt;
                                  &lt;/select&gt;
                              &lt;/div&gt;
                              &lt;div class="checkbox"&gt;
                                  &lt;label&gt;
                                      &lt;input name="remember" id="remember" type="checkbox" value="Remember Me"&gt;Remember Me
                                  &lt;/label&gt;
                              &lt;/div&gt;
                              &lt;!-- Change this to a button or input when using this as a form --&gt;
                              &lt;input type="submit" name="signup" id="signup" value="Signup" class="btn btn-lg btn-primary btn-block"&gt;
  
                          &lt;/fieldset&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>