我想創建一個簡單的註冊表單。我有以下幾點:這個註冊表格缺少什麼工作?
include('User.datatype.php');
class NewUser {
function inquireSubmit() {
if(isset($_POST['register'])) {
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
}
else {
exit;
}
}
function registerUser() {
if ($username = '' or $password = '') {
$msg = 'Please enter the required information.';
header('Location: index.php?error=$msg');
}
else {
$user = new User;
$user->username = $username;
$user->password = $password;
$user->profile = $profile;
}
}
}
class UserManager {
public function storeData() {
$database = mysql_connect("localhost", "root", "");
mysql_select_db("test") or die(mysql_error());
$username_e = mysql_real_escape_string($NewUser->username);
$password_e = mysql_real_escape_string($NewUser->password);
$query = "INSERT INTO users (username, password) VALUES ($username_e, $password_e)";
mysql_query($query);
}
}
下面是HTML表單:
<form id="register" action="register.php">
<table cellpadding="2" cellspacing="2" border="0">
<tr valign="top">
<td>
Username: <input name="username" type="text" id="username" />
</td>
</tr>
<tr valign="top">
<td>
Password: <input name="password" type="password" id="password" />
</td>
<td>
<button id="register">Register</button>
</td>
</tr>
</table>
</form>
每當我測試了一下,我只是得到了一個空白頁面的結果。我做錯了什麼?另外,(和哪裏)在成功或失敗時顯示確認消息?提前謝謝了!
似乎有相當多的東西正在進行一個簡單的註冊頁面。我會做一些類似於創建一個名爲(或類似於)'register_me($ un,$ pw)'的函數,並傳遞來自'username'和'password'的值。然後在函數內部,讓查詢檢查用戶是否已經存在;如果沒有,插入表中。如果是這樣,顯示一個錯誤,並顯示登錄或忘記密碼的東西。 – dan