I was just making a simple registration form but suddenly run into a weird problem I’ve not had before. I can’t seem to assign and POST vars to variables or simply echo specific ones out. Though I can print_r/var_dump POST contents fine.
<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
The Firebug says there’s a 500 internal server error going on but I can’t understand why. Maybe someone has experienced this before?
Form code if it helps:
<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>
You are using parentheses instead of brackets. $_POST is an array, not a function. Try: