2012-01-04 45 views
0

我只是做一個簡單的登記表,但突然遇到一個奇怪的問題,我以前沒有過不可訪問。我似乎無法分配和POST變量變量或簡單地echo具體的了。雖然我可以print_r的精細/ POST的var_dump內容。POST變量儘管是有

<html> 
<head> 
<title>Register</title> 
</head> 
<body> 
<?php 
error_reporting(E_ALL); ini_set('display_errors', true); 
echo 'cheese'; 
var_dump($_POST); //Works here 
$test = $_POST('username'); //Stops working here 

的螢火蟲說,有一個500內部服務器錯誤怎麼回事,但我不明白爲什麼。也許有人以前經歷過這個?

表單代碼是否有幫助:

<form method="post" action="cl-register.php"> 
     <div style="width:100px;float:left">Username</div> <input type="text" size="15" name="username" id="username" /><br /> 
     <div style="width:100px;float:left">Password</div> <input type="password" size="15" name="password" /><br /> 
     <div style="width:100px;float:left">Email</div> <input type="text" size="25" name="email" /><br /> 
     <input type="submit" value="Register!" /> 
</form> 

回答

4

您使用括號,而不是括號。 $ _POST是一個數組,不是一個函數。嘗試:

$test = $_POST['username']; 
+0

現在我覺得自己很蠢,有多少次我用方括號寫呢?數太多了。但是沒有,這次我做了一個特別的。儘管歡迎儘快回覆。 x.x中 – Crimsonfox 2012-01-04 22:11:43

2

$_POST是一個數組,你通過方括號訪問值:

$test = $_POST['username'];