Search code examples
phphtmlregistryparse-error

Unknown error for basic registration


i have this error

Parse error: syntax error, unexpected '{' in receive/register.php on line 1

My receive/register.php is

<?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';
}
?>

And the one that sends the info is

<?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'] = '';
*/

Solution

  • shouldn't it be:

    $username = $_POST['username'];
    $password = $_POST['password'];
    

    etc....

    When I used your code I got $username is undefined error on php 5.3.5

    also noticed... if you're using $_SESSION you need to add

    session_start();
    

    at the top of your code