title: Keep me logged in php function using modal dialog login form
body: <p>I want to do is when I check the checkbox button in my dialog box the email and the password that I've typed on it will be saved and redirect to profile.php.</p>
  
  <p>My problem is it doesn't work and I have an error in the inputbox that says: </p>
  
  <blockquote>
    <p>Undefined index: unm and  Undefined index: pwd</p>
  </blockquote>
  
  <p>Does anyone here can help me with my problem?</p>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['login'])) {
      if(isset($_POST['chkbox'])) {
          setcookie("unm",$_POST['email'],time()+3600);
          setcookie("pwd",$_POST['password'],time()+3600);
      }
      ?&gt;
      &lt;script type="text/javascript"&gt;
          window.location="profile.php";
      &lt;/script&gt;
      &lt;?php
  }
  ?&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;a data-toggle="modal" href="#myModal"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; Login&lt;/a&gt;
  
          &lt;div class="container"&gt;
              &lt;div class="row"&gt;
                      &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true"&gt;
                          &lt;div class="modal-dialog"&gt;
                              &lt;div class="modal-content"&gt;
                                  &lt;div class="modal-header"&gt;
                                      &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
                                      &lt;h5 class="modal-title"&gt;PLEASE ENTER YOUR EMAIL ADDRESS AND PASSWORD TO LOG IN.&lt;/h5&gt;
                                  &lt;/div&gt;
                                  &lt;div class="modal-body"&gt;
                                      &lt;form class="form-horizontal"&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;label for="email" class="col-sm-2 control-label"&gt;Email&lt;/label&gt;
                                              &lt;div class="col-md-9"&gt;
                                                  &lt;div class="input-group"&gt;
                                                      &lt;span class="input-group-addon"&gt;&lt;i class="fa fa-envelope-o fa-fw"&gt;&lt;/i&gt;&lt;/span&gt;
                                                      &lt;input type="text" name="email" value="&lt;?php echo $_COOKIE['unm'] ?&gt;" class="form-control" placeholder="Enter Email Address..." /&gt;
                                                  &lt;/div&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;label for="password" class="col-sm-2 control-label"&gt;Password&lt;/label&gt;
                                              &lt;div class="col-md-9"&gt;
                                                  &lt;div class="input-group"&gt;
                                                      &lt;span class="input-group-addon"&gt;&lt;i class="fa fa-key fa-fw"&gt;&lt;/i&gt;&lt;/span&gt;
                                                      &lt;input type="password" name="password" value="&lt;?php echo $_COOKIE['pwd'] ?&gt;" class="form-control" placeholder="Enter Password..." /&gt;
                                                  &lt;/div&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                                                  &lt;input type="checkbox" name="chkbox" value="staylogged" class="checkbox-inline" /&gt;
                                                  &lt;label&gt;  &amp;nbsp; Keep me logged in&lt;/label&gt;  &amp;nbsp; &lt;b&gt;|&lt;/b&gt;
                                                  &lt;a href="" style="text-decoration:none"&gt;  &amp;nbsp; Forgot your password?&lt;/a&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div class="form-group"&gt;
                                              &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                                                  &lt;button type="submit" name="login" class="btn btn-primary"&gt;&lt;span class="glyphicon glyphicon-user"&gt;&lt;/span&gt; Login&lt;/button&gt;
                                                  &lt;button type="button" id="show_signup_md" class="btn btn-info" data-dismiss="modal" aria-hidden="true"&gt;&lt;span class="glyphicon glyphicon-list-alt"&gt;&lt;/span&gt; Register&lt;/button&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/form&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>