我有这个错误
Parse error: syntax error, unexpected '{' in receive/register.php on line 1
我的接收/ register.php是
<?php
$_POST['username'] = $username;
$_POST['password1'] = $password;
$_POST['password2'] = $passwordagain;
$_POST['email'] = $email;
echo $username.'<br>'.$password.'<br>'.$passwordagain.'<br>'.$email;
if (!isset($username) || !isset($password) || !isset($passwordagain) || !isset($email))
{ /*
$_SESSION['regerrorid'] = '0';
$_SESSION['regerrormsg'] = 'Not all fields are completed';
header ('Location: ./'.$directory.'register');*/
echo'uhm';
}
?>
发送信息的是
<?php
/* !!!!only if the code works
$_SESSION['regerrorid'] = $success;
$_SESSION['regerrormsg'] = $message;
*/
?>
<div class='registration-<?php echo $success; ?>'><?php echo $message; ?></div><br>
<form action="receive/register.php" method="POST">
<span style='font-size:14px;font-family:"Lucida Console", Monaco, monospace'>Username:</span><input class='lolquired' type="text" name="username" /><br />
<span style='font-size:14px;font-family:"Lucida Console", Monaco, monospace'>Password:</span><input class='lolquired' type="password" name="password1" /><br />
<span style='margin-left:-56px;font-size:14px;font-family:"Lucida Console", Monaco, monospace'>Repeat Password:</span><input class='lolquired' type="password" name="password2" /><br />
<span style='margin-left:24px;font-size:14px;font-family:"Lucida Console", Monaco, monospace'>Email:</span><input class='lolquired' type="email" name="email" /><br /><br />
<input class="button" type="submit" value="Submit" />
</form><?php
/* !!!!only if the code works
$_SESSION['regerrorid'] = '';
$_SESSION['regerrormsg'] = '';
*/
答案 0 :(得分:1)
不应该是:
$username = $_POST['username'];
$password = $_POST['password'];
等...
当我使用你的代码时,我在PHP 5.3.5上获得$ username是未定义的错误
还注意到......如果您使用$ _SESSION,则需要添加
session_start();
位于代码顶部