else if else
Posted: Mon Dec 30, 2013 2:04 am
Hey following videos I was trying to change something but it didnt work, there is a code:
I am not asking you to make it for me or anything, but give me some info what is wrong here. I guess that when I start with "if" then it follow up with "else if" then "else" but is there any way to add more to it? I mean more "elses" so I can keep checking more and more at once or is there a better way? I can see in that code name/passwords are together if/else if/else and then there is an exit and another else for email. I will try to figure out how that works and maybe I will manage.
If password1 does not match pass2
echo pass1 does not match pass2
else if check if password is not too long (if password1 match password2 then there is else if )
echo password is too long
else check if password is not too short(if else if fails too which means in this case password is not too long then there is another else)
echo password is too short(and lastly if password match pass2 its not too short or too long then its all good but I might want to add more else, which give me an error of unexpected else.)
exit
and now what? is it all I can do? I want to add another line depending on what might happen. I know its not necessary and I could just follow video and put all in one place but I want to try different ways. Of course before someone answer me I will try to find solution by myself. If I do I will post here again. Thanks
Sorry if this post is messed up ^^
@edit:
when I play with that else and change it, for some reason I keep getting syntax error, unexpected 'else' in different places when I add/delete }{ to make it work
I am still trying.
Code: Select all
if(!$_POST['password'] || !$_POST['password2'])
{
print "You did not enter a password<br>";
echo "<A href='register.php'>Go back</a>";
exit;
}
else if($isplayer3)
{
print "There is already a player of that name";
echo "<A href='register.php'>Go back</a>";
else (strlen($player)>21 || strlen($player)<5)
print "The name you specified must be between 5-21 characters long<br>";
echo "<A href='register.php'>Go back<a>";
exit;
If password1 does not match pass2
echo pass1 does not match pass2
else if check if password is not too long (if password1 match password2 then there is else if )
echo password is too long
else check if password is not too short(if else if fails too which means in this case password is not too long then there is another else)
echo password is too short(and lastly if password match pass2 its not too short or too long then its all good but I might want to add more else, which give me an error of unexpected else.)
exit
and now what? is it all I can do? I want to add another line depending on what might happen. I know its not necessary and I could just follow video and put all in one place but I want to try different ways. Of course before someone answer me I will try to find solution by myself. If I do I will post here again. Thanks

Sorry if this post is messed up ^^
@edit:
when I play with that else and change it, for some reason I keep getting syntax error, unexpected 'else' in different places when I add/delete }{ to make it work
