2017-11-29 22 views
-1

私は完全な初心者です。大学でプロジェクトのためのフォームを作成しようとしています。私はちょうどPHPを学んでいると私は私のデータベースにリンクするに移動する前に、私は私のPHPフォームから値を取って出力することができますかどうかをテストしようとしています。これは私のログインページの完全なコードで、btwはフレームワークのいくつかのためにブートストラップを使用しました。だから私はPOSTメソッドを使用しようとし、それが動作するかどうかを確認するために姓と名をエコーし​​、送信ボタンを押したときにエコーアウトしません。これは本当にイライラしています。スタイルについて心配する必要はありません、私はちょうど最初から機能を取り出そうとしています、そして、はい、そのページはindex.phpと呼ばれています。PHP POSTメソッドが機能していませんか?

<!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>

+0

それを使用して、この行に

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

のですか?いくつかのロジックがありません。それがdbconnect.phpに入っていない限り –

+0

@ cpt-crunchy pedrams shabaniが小さなエラーを見つけたのを心配しないでください。チェックしていただきありがとうございます!コードは未完成で、必要な値を取得しているかどうかをテストするためにのみ使用しています。 – TomCreed

答えて

1

あなたの間違いは、あなたがフォームから受け取ったデータを "投稿" されている場合

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

あなたがどれくらいの間、私は間違いを探していたのですか? Idk私はそれを逃していた可能性があります。新鮮な目を持つのが良い。私はおそらくそれを10000000回見ました。 – TomCreed

関連する問題