2014-02-09 62 views
0

所以我做了一個註冊表單,除了當我按下注冊時它應該可以正常工作,它應該給我回註冊但是它不是我不知道爲什麼在代碼中的錯誤因爲我沒有看到它,請幫我在這裏..我沒有得到提交按鈕,當我按下注冊(註冊/登錄系統的PHP)

register.php: 

<?php 

require_once 'core/init.php'; 

if(input::exists()) { 
echo 'Submitted'; 
} 

?> 


<form action="" method=""> 
    <div class="field"> 
     <label for="username">Username</label> 
     <input type="text" name="username" id="username" value="" autocomplete="off"> 
    </div> 

    <div class="field"> 
     <label for="password">Create a password</label> 
     <input type="password" name="password" id="password"> 
    </div> 

    <div class="field"> 
     <label for="password_again">Enter your password again</label> 
     <input type="password" name="password_again" id="password_again"> 
    </div> 

    <div class="field"> 
     <label for="name">Enter your password again</label> 
     <input type="text" name="name" id="name"> 
    </div> 

    <input type="submit" value="Register" 

input.php:

<?php 
class input { 
    public static function exists($type = 'post') { 
     switch($type) { 
      case 'post': 
       return (!empty($_POST)) ? true : false; 
      break; 
      case 'get': 
       return (!empty($_GET)) ? true : false; 
      break; 
      default: 
       return false; 
      break; 
     } 
    } 
} 

和的init.php

<?php 
session_start(); 

$GLOBALS ['config'] = array(
    'mysql' => array(
     'host' => '127.0.0.1', 
     'username' => 'root', 
     'password' => '', 
     'db' => 'lr' 
    ), 
    'remember' => array(
     'cookie_name' => 'hash', 
     'cookie_expiry' => 604800 
     ), 
    'session' => array(
     'session_name' => 'user' 
    ) 
); 

spl_autoload_register(function($class) { 
    require_once 'classes/' . $class . '.php'; 

}); 

require_once 'functions/sanitize.php'; 
?> 

回答

0

我發現這個問題

<form action="" method=""> 

忘了後它

<form action="" method="post"> 
0

按鈕沒有關閉

你有

<input type="submit" value="Register" 

應該

<input type="submit" value="Register"> 

更多在形式需要被關閉

</form> 

也有你的表單動作=「」這將需要$ _GET [「用戶名」]等獲得值 在函數exists()默認類型是後,所以你將需要設置表單方法爲後或調用

if(input::exists()) { 
echo 'Submitted'; 
} 

你應該做的

if(input::exists("get")) { 
echo 'Submitted'; 
} 

因此,在第二種情況,你可以保持表單行動 「」

+0

但我仍然沒有得到提交的文字時,我按下按鈕 – lenart95

+0

檢查我的更新回答。 –