PHP POST方法不起作用?

时间:2017-11-29 22:27:26

标签: php mysql

我是一个完全的初学者,我正在尝试为大学的项目制作表格。我只是在学习php而且我正在尝试测试我是否可以从我的php表单中获取值并在我继续将其链接到我的数据库之前将其输出。这是我的登录页面的完整代码,我使用bootstrap进行一些框架工作。所以我尝试使用POST方法并回显出名字和姓氏以查看它是否有效,当我按下提交按钮时它就不会回响。这真让我很沮丧。不要担心样式,我只想先将功能放在首位,是的,页面名为index.php。

<!doctype html>
<html lang='en'>
  <head>
    <title>Create Employee Account</title>
    
    <!-- Required meta tags -->
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>

    <!-- Bootstrap CSS -->
    <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css' >
    
    
    <link rel='stylesheet' href='no_dashboard_css_template.css'> 
    <link rel='stylesheet' href= ''>
  </head>

  <body>
  
<?php
include 'dbconnect.php';

if(isset($POST['submit']))
{
    $firstName=$_POST['firstname'];
    $lastName=$_POST['lastname'];
    $email=$_POST['email'];
    $password1=$_POST['password1'];
    $password2=$_POST['password2'];
}
echo $firstName;
echo $lastName;

?>
   
      
                             <!-- NAVIGATION BAR -->     
                             
  <nav class='navbar navbar-expand-lg navbar-light bg-light'>
   <img id='logo' src='logo.png'>
   <button class='navbar-toggler' type='button' data-toggle='collapse' data-target='#navbarSupportedContent' aria-controls='navbarSupportedContent' aria-expanded='false' aria-label='Toggle navigation'>
   <span class='navbar-toggler-icon'></span>
   </button>
  
   <div class='collapse navbar-collapse' id='navbarSupportedContent'>
    <ul class='navbar-nav mr-auto'>
      <li class='nav-item active'>
        <a class='nav-link' href='#'>Home/Login<span class='sr-only'>(current)</span></a>
      </li>
    </ul>
   </div>
  </nav>
                  <!-- Main CONTAINER part of the page WHERE MOST PAGE CONTENT WILL GO -->
<div class='container-fluid'>

<div class='row'>
    
                  <!-- EMPLOYEE SIGN UP AREA -->

<div class='col-lg-4'>  
<h3>Potential Employee Sign Up</h3>    

                   <!-- EMPLOYEE SIGN UP FORM -->
<form action='index.php' method='POST' >
 
                   <!-- Title (Mr Mrs etc. -->
 <label class='mr-sm-2' for='inlineFormCustomSelectPref'>Title</label>
 <select name='title' class='custom-select mb-2 mr-sm-2 mb-sm-0' id='inlineFormCustomSelectPref'>
    <option selected>Choose...</option>
    <option value='1'>Mr</option>
    <option value='2'>Ms</option>
    <option value='3'>Mrs</option>
  </select>
  <br>
  
                    <!-- NAMES -->
  <div class='row'>

  <!-- First Name -->
    <div class='col'>
      <input type='text' class='form-control' name='firstname' placeholder='First name'>
    </div>
 
  <!-- Last Name -->
    <div class='col'>
      <input type='text' class='form-control' name='lastname' placeholder='Last name'>
    </div>
  </div>

                    <!-- Email and Password-->
  <div class='form-group'>
    <label for='exampleInputEmail1'>Email address</label>
    <input type='text' class='form-control' id='exampleInputEmail1' name='email' placeholder='Enter email'>
  </div>
  <div class='form-group'>
    <label for='exampleInputPassword1'>Password:</label>
    <input type='password' class='form-control' name='password1' id='exampleInputPassword1' placeholder='Password'>
    <label for='exampleInputPassword1'>Enter your Password again:</label>
    <input type='password' class='form-control' name='password2' id='exampleInputPassword1' placeholder='Password'>
  </div>
                    <!-- Terms and Conditions-->
  <div class='form-check'>
    <label class='form-check-label'>
      <input type='checkbox' class='form-check-input'>
      I have agreed and read the Terms and conditions
    </label>
  </div>
  
                    <!-- Education -->
                    <!-- University -->
    <div class='form-group'>
    <label for='exampleFormControlInput1'>University</label>
    <input type='text' class='form-control' name='uni' id='exampleFormControlInput1' placeholder='Please Type your University'>
  </div>
                    <!-- Degree Type -->
  <label class='mr-sm-2' for='inlineFormCustomSelectPref'>Degree Type</label>
  <select class='custom-select mb-2 mr-sm-2 mb-sm-0' name='degtype' id='inlineFormCustomSelectPref'>
    <option selected>Choose...</option>
    <option value='1'>BEng</option>
    <option value='2'>MEng</option>
    <option value='3'>MSc</option>
  </select> 
  <br>
                    <!-- End Button to submit -->
  <button type='submit' class='btn btn-primary' name='submit' >Sign Up!</button>
  

</form>
     
    </div>
  </div>
</div>

                  <!-- EMPLOYEE SIGN UP AREA END -->
                  
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src='https://code.jquery.com/jquery-3.2.1.slim.min.js' ></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js' ></script>
    <script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js' ></script>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

你的错误就在这条线上

if(isset($POST['submit']))

使用它

if(isset($ـPOST['submit']))