I'm new to PHP and I'm currently trying to write a login system, but I keep getting an error which I think is something really simple. But I just can't figure it out and I've looked on the internet but found nothing.
Some code didn't fit so you will see where it needs to be placed back together it's obvious,
Error is
Parse error: syntax error, unexpected ':' in C:... on line 28
Here is all the code I've got and I'm writing it in Atom.
<?php
//Bug list
//R101=Username uses Invalid characters
//R102=USERNAME IS NOT LONG ENOUGH OR TO SHORT
//R103=USERNAME ALREADY EXISTS IN DATABASE
//R104 Email used is not a proper email
//R105=Password too short or long
include('classes/DB.php');
if (isset( $_POST['createaccount'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
if (!DB::query('SELECT username FROM users WHERE
username=:username',array(':username'=>$username))) {
//CHECK IF USERNAME IS LONG ENOUGH
if (strl($username) >= 4 && strlen($username <= 32)){
//CHECK FOR VALID CHARACTERS
if(preg_match('/[a-zA-Z0-9_]+/', $username)){
if (filter_var($email,FILTER_VALIDATE_EMAIL)){
if (strlen($password) >= 6 && strlen($password) <= 60){
//USERNAME IS VALID AND WILL NOW BE CREATED
DB::query('INSERT INTO users VALUES (\'\
',:username, :password, :email)', array(':username'=>$username,
':password'=>password_hash($password, PASSWORD_BCRYPT), ':email'=> $email));
echo 'Success';
} else {
"Password Invalid (R105)"
}
} else {
echo "Username Invalid (R104)"
}
} else {
echo "Username Invalid (R101) "
}
} else {
echo "Username Invalid (R102)"
}
} else {
echo 'Username Is Taken (R103)';
}
}
?>
<h1>Register</h1>
<form action="create-account.php" method="post">
<input type="text" name="username" value="" placeholder="Username"><p />
<input type="password" name="password" value="" placeholder="Password"><p />
<input type="email" name="email" value="" placeholder="name@email.com"><p />
<input type="submit" name="createaccount" value="Create Account">
</form>